Skip to content

Commit f529dfa

Browse files
yungu0010claude
andcommitted
[Fix] force push 시 BEFORE_SHA 유효하지 않아 diff 실패하는 문제 수정
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c501d98 commit f529dfa

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

.github/workflows/style-dictionary.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff 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)]);

0 commit comments

Comments
 (0)