Skip to content

Commit

Permalink
fix(ng-dev/pr): Use --deepen in place of --depth during fetches i…
Browse files Browse the repository at this point in the history
…n rebasing

Previously we used `--depth` to ensure that enough commits were included in the repository to effectively
perform rebases.  However, using `--depth` sets the depth of the repository, and if the repository previously
was unshallow, it because a shallow repository.  Instead by using deepen, the depth will be increased by the
provided value.  This will ensure that the enough commits are included and will be a noop if an unshallow
repo is deepened further.
  • Loading branch information
josephperrott authored and devversion committed Sep 14, 2021
1 parent 5e1f351 commit 9416a56
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions github-actions/slash-commands/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49860,10 +49860,10 @@ var require_rebase = __commonJS({
}
try {
(0, console_1.info)(`Checking out PR #${prNumber} from ${fullHeadRef}`);
git.run(["fetch", "-q", headRefUrl, headRefName, "--depth=500"]);
git.run(["fetch", "-q", headRefUrl, headRefName, "--deepen=500"]);
git.run(["checkout", "-q", "--detach", "FETCH_HEAD"]);
(0, console_1.info)(`Fetching ${fullBaseRef} to rebase #${prNumber} on`);
git.run(["fetch", "-q", baseRefUrl, baseRefName, "--depth=500"]);
git.run(["fetch", "-q", baseRefUrl, baseRefName, "--deepen=500"]);
const commonAncestorSha = git.run(["merge-base", "HEAD", "FETCH_HEAD"]).stdout.trim();
const commits = await (0, utils_12.getCommitsInRange)(commonAncestorSha, "HEAD");
let squashFixups = process.env["CI"] !== void 0 || commits.filter((commit) => commit.isFixup).length === 0 ? false : await (0, console_1.promptConfirm)(`PR #${prNumber} contains fixup commits, would you like to squash them during rebase?`, true);
Expand Down
6 changes: 3 additions & 3 deletions ng-dev/pr/rebase/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ export async function rebasePr(prNumber: number, githubToken: string): Promise<n
}

try {
// Fetches are done with --depth=500 increase the likelihood of finding a common ancestor when
// Fetches are done with --deepen=500 increase the likelihood of finding a common ancestor when
// a shallow clone is being used.

// Fetch the branch at the commit of the PR, and check it out in a detached state.
info(`Checking out PR #${prNumber} from ${fullHeadRef}`);
git.run(['fetch', '-q', headRefUrl, headRefName, '--depth=500']);
git.run(['fetch', '-q', headRefUrl, headRefName, '--deepen=500']);
git.run(['checkout', '-q', '--detach', 'FETCH_HEAD']);
// Fetch the PRs target branch and rebase onto it.
info(`Fetching ${fullBaseRef} to rebase #${prNumber} on`);
git.run(['fetch', '-q', baseRefUrl, baseRefName, '--depth=500']);
git.run(['fetch', '-q', baseRefUrl, baseRefName, '--deepen=500']);

const commonAncestorSha = git.run(['merge-base', 'HEAD', 'FETCH_HEAD']).stdout.trim();

Expand Down

0 comments on commit 9416a56

Please sign in to comment.