소스 검색

Fixes diff to uncommitted

main
Eric Amodio 1 년 전
부모
커밋
6858c2a715
2개의 변경된 파일17개의 추가작업 그리고 6개의 파일을 삭제
  1. +3
    -3
      src/ai/aiProviderService.ts
  2. +14
    -3
      src/env/node/git/localGitProvider.ts

+ 3
- 3
src/ai/aiProviderService.ts 파일 보기

@ -75,9 +75,9 @@ export class AIProviderService implements Disposable {
if (repository == null) throw new Error('Unable to find repository');
let diff = await this.container.git.getDiff(repository.uri, uncommittedStaged);
if (diff == null) {
if (!diff?.contents) {
diff = await this.container.git.getDiff(repository.uri, uncommitted);
if (diff == null) throw new Error('No changes to generate a commit message from.');
if (!diff?.contents) throw new Error('No changes to generate a commit message from.');
}
if (options?.cancellation?.isCancellationRequested) return undefined;
@ -128,7 +128,7 @@ export class AIProviderService implements Disposable {
if (commit == null) throw new Error('Unable to find commit');
const diff = await this.container.git.getDiff(commit.repoPath, commit.sha);
if (diff == null) throw new Error('No changes found to explain.');
if (!diff?.contents) throw new Error('No changes found to explain.');
const provider = this.provider;

+ 14
- 3
src/env/node/git/localGitProvider.ts 파일 보기

@ -2744,17 +2744,22 @@ export class LocalGitProvider implements GitProvider, Disposable {
ref2?: string,
options?: { context?: number },
): Promise<GitDiff | undefined> {
const scope = getLogScope();
const params = [`-U${options?.context ?? 3}`];
if (ref1 === uncommitted) {
if (ref2 != null) {
params.push(ref2);
} else {
// Get only unstaged changes
ref2 = 'HEAD';
}
} else if (ref1 === uncommittedStaged) {
// Get up to staged changes
params.push('--staged');
if (ref2 != null) {
params.push(ref2);
} else {
// Get only staged changes
ref2 = 'HEAD';
}
} else if (ref2 == null) {
@ -2769,8 +2774,14 @@ export class LocalGitProvider implements GitProvider, Disposable {
params.push(ref1, ref2);
}
const data = await this.git.diff2(repoPath, undefined, ...params);
if (!data) return undefined;
let data;
try {
data = await this.git.diff2(repoPath, { errors: GitErrorHandling.Throw }, ...params);
} catch (ex) {
debugger;
Logger.error(ex, scope);
return undefined;
}
const diff: GitDiff = { baseSha: ref2, contents: data };
return diff;

불러오는 중...
취소
저장