cli: fall back --since diff to use ref if merge base lookup fails
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
The `--since` flag of repo commands now silently falls back to using the provided `ref` directly if no merge base is available.
|
||||
@@ -50,9 +50,16 @@ export async function listChangedFiles(ref: string) {
|
||||
if (!ref) {
|
||||
throw new Error('ref is required');
|
||||
}
|
||||
const [base] = await runGit('merge-base', 'HEAD', ref);
|
||||
|
||||
const tracked = await runGit('diff', '--name-only', base);
|
||||
let diffRef = ref;
|
||||
try {
|
||||
const [base] = await runGit('merge-base', 'HEAD', ref);
|
||||
diffRef = base;
|
||||
} catch {
|
||||
// silently fall back to using the ref directly if merge base is not available
|
||||
}
|
||||
|
||||
const tracked = await runGit('diff', '--name-only', diffRef);
|
||||
const untracked = await runGit('ls-files', '--others', '--exclude-standard');
|
||||
|
||||
return Array.from(new Set([...tracked, ...untracked]));
|
||||
|
||||
Reference in New Issue
Block a user