Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/local-actions/branch-manager/main.js

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions ng-dev/pr/merge/strategies/autosquash-merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,37 @@ import {MergeConflictsFatalError} from '../failures.js';
* fast-forward merges.
*/
export class AutosquashMergeStrategy extends MergeStrategy {
/**
* To determine if an autosquash merge will succeed, we must dry-run the autosquash rebase. The
* default `check` method relies on `git cherry-pick`, which applies fixups sequentially rather
* than squashing them, and fails to catch conflicts caused by the squashing process.
*/
override async check(pullRequest: PullRequest): Promise<void> {
/** The original SHA, so that we can restore the temporary branch */
const originalHeadSha = this.git.run(['rev-parse', TEMP_PR_HEAD_BRANCH]).stdout.trim();
const branchOrRevisionBeforeRebase = this.git.getCurrentBranchOrRevision();

try {
try {
this.git.run(
['rebase', '--interactive', '--autosquash', pullRequest.baseSha, TEMP_PR_HEAD_BRANCH],
{
env: {...process.env, GIT_SEQUENCE_EDITOR: 'true'},
},
);
} catch (e) {
this.git.runGraceful(['rebase', '--abort']);
throw new MergeConflictsFatalError([]);
}

await super.check(pullRequest);
} finally {
// Restore the temporary branch after checks.
this.git.run(['update-ref', `refs/heads/${TEMP_PR_HEAD_BRANCH}`, originalHeadSha]);
// Restore the original checked out branch/revision to clean up the working tree.
this.git.run(['checkout', '-f', branchOrRevisionBeforeRebase]);
}
}
Comment thread
josephperrott marked this conversation as resolved.
/**
* Merges the specified pull request into the target branches and pushes the target
* branches upstream. This method requires the temporary target branches to be fetched
Expand Down