Skip to content

Commit

Permalink
deepenGitHistory: fetch from HEAD only
Browse files Browse the repository at this point in the history
  • Loading branch information
cklin committed Dec 6, 2024
1 parent 6f9e628 commit ada480e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 5 deletions.
13 changes: 11 additions & 2 deletions lib/actions-util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/actions-util.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/analyze.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze.js.map

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion src/actions-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,27 @@ export const deepenGitHistory = async function () {
try {
await runGitCommand(
getOptionalInput("checkout_path"),
["fetch", "--no-tags", "--deepen=1"],
["fetch", "origin", "HEAD", "--no-tags", "--deepen=1"],
"Cannot deepen the shallow repository.",
);
} catch {
// Errors are already logged by runGitCommand()
}
};

export const gitRepack = async function () {
try {
await runGitCommand(
getOptionalInput("checkout_path"),
["repack", "-d"],
"Cannot repack the repository.",
);
}
catch {
// Errors are already logged by runGitCommand()
}
};

/**
* Fetch the given remote branch. Errors are logged.
*
Expand Down
1 change: 1 addition & 0 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ async function getPullRequestEditedDiffRanges(
await actionsUtil.gitFetch(baseRef, [`--shallow-exclude=${headRef}`]);
// Step 5: Deepen the history so that we have the merge bases between the base
// branch and the PR topic branch.
await actionsUtil.gitRepack();
await actionsUtil.deepenGitHistory();

// To compute the exact same diff as GitHub would compute for the PR, we need
Expand Down

0 comments on commit ada480e

Please sign in to comment.