feat(git): improve PR panel (#207)
This commit is contained in:
committed by
GitHub
parent
614277eaa1
commit
da20c647e2
@@ -699,7 +699,18 @@ export async function getGitRangeDiff(
|
||||
if (!baseRef || !headRef) {
|
||||
return { diff: '' };
|
||||
}
|
||||
const args = ['diff', '--no-color', `-U${Math.max(0, contextLines)}`, `${baseRef}...${headRef}`, '--', filePath];
|
||||
|
||||
let resolvedBase = baseRef;
|
||||
try {
|
||||
const verify = await execGit(['rev-parse', '--verify', `refs/remotes/origin/${baseRef}`], directory);
|
||||
if (verify.exitCode === 0) {
|
||||
resolvedBase = `origin/${baseRef}`;
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
const args = ['diff', '--no-color', `-U${Math.max(0, contextLines)}`, `${resolvedBase}...${headRef}`, '--', filePath];
|
||||
const result = await execGit(args, directory);
|
||||
return { diff: result.stdout };
|
||||
}
|
||||
@@ -717,7 +728,18 @@ export async function getGitRangeFiles(
|
||||
if (!baseRef || !headRef) {
|
||||
return [];
|
||||
}
|
||||
const args = ['diff', '--name-only', `${baseRef}...${headRef}`];
|
||||
|
||||
let resolvedBase = baseRef;
|
||||
try {
|
||||
const verify = await execGit(['rev-parse', '--verify', `refs/remotes/origin/${baseRef}`], directory);
|
||||
if (verify.exitCode === 0) {
|
||||
resolvedBase = `origin/${baseRef}`;
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
const args = ['diff', '--name-only', `${resolvedBase}...${headRef}`];
|
||||
const result = await execGit(args, directory);
|
||||
if (result.exitCode !== 0) return [];
|
||||
return String(result.stdout || '')
|
||||
|
||||
Reference in New Issue
Block a user