File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,14 +60,27 @@ jobs:
6060 const beforeSha = process.env.BEFORE_SHA;
6161 const afterSha = process.env.AFTER_SHA;
6262
63- const changedFiles = execSync(
64- `git diff --name-only ${beforeSha} ${afterSha} -- tokens/`
65- ).toString().trim().split('\n').filter(f => f.endsWith('.json'));
63+ function isValidSha(sha) {
64+ try { execSync(`git cat-file -e ${sha}`); return true; } catch { return false; }
65+ }
66+
67+ function resolveBase(afterSha) {
68+ if (beforeSha && isValidSha(beforeSha)) return beforeSha;
69+ try {
70+ return execSync(`git merge-base ${afterSha} origin/default`).toString().trim();
71+ } catch { return null; }
72+ }
73+
74+ const baseSha = resolveBase(afterSha);
75+ const changedFiles = baseSha
76+ ? execSync(`git diff --name-only ${baseSha} ${afterSha} -- tokens/`)
77+ .toString().trim().split('\n').filter(f => f.endsWith('.json'))
78+ : [];
6679
6780 const rows = [];
6881 for (const file of changedFiles) {
6982 let before = {}, after = {};
70- try { before = parseTokenFile(execSync(`git show ${beforeSha }:${file}`).toString()); } catch {}
83+ try { before = parseTokenFile(execSync(`git show ${baseSha }:${file}`).toString()); } catch {}
7184 try { after = parseTokenFile(fs.readFileSync(file, 'utf-8')); } catch {}
7285
7386 const keys = new Set([...Object.keys(before), ...Object.keys(after)]);
You can’t perform that action at this time.
0 commit comments