Skip to content

Commit

Permalink
fix(scripts/diff-features): fetch missing ref (#25679)
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner authored Jan 17, 2025
1 parent 6440d59 commit 3fd5f96
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions scripts/diff-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,24 @@ const enumerateFeatures = (ref = 'HEAD', quiet = false): string[] => {
// However, if `ref` is already checked out, then `git worktree add` fails. As
// long as you haven't checked out a detached HEAD for `ref`, then
// `git worktree add` for the hash succeeds.
const hash = execSync(`git rev-parse --short ${ref}`, {
encoding: 'utf-8',
}).trim();
const hash = (() => {
try {
return execSync(`git rev-parse --short ${ref}`, {
encoding: 'utf-8',
}).trim();
} catch (e) {
// See: https://github.com/mdn/browser-compat-data/issues/25678
if (process.env.GITHUB_ACTIONS === 'true') {
console.error(`::error::${e}`);
}

execSync(`git fetch origin ${ref}`);

return execSync(`git rev-parse --short ${ref}`, {
encoding: 'utf-8',
}).trim();
}
})();

const worktree = `__enumerating__${hash}`;

Expand Down

0 comments on commit 3fd5f96

Please sign in to comment.