Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

rebase-tool: Allow 'continue' and 'finish' to work in exec step #291

Merged
merged 1 commit into from
Jan 13, 2025
Merged
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
22 changes: 19 additions & 3 deletions tools/rebase-upstream-commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,19 @@ function editSequenceFile(file: string) {
}

function getConflictHash() {
const REBASE_CONFLICT_HASH_FILE = `${currentExecOpts.repository}/.git/rebase-merge/stopped-sha`;
if (!fs.existsSync(REBASE_CONFLICT_HASH_FILE)) {
// This is easily available from .git/rebase-merge/stopped-sha if there is a
// merge conflict, but we may also be stopped in the middle of an exec step,
// where that file doesn't exist. Instead, get it from the 'done' list.
const REBASE_DONE_FILE = `${currentExecOpts.repository}/.git/rebase-merge/done`;
if (!fs.existsSync(REBASE_DONE_FILE)) {
return undefined;
}
return String(fs.readFileSync(REBASE_CONFLICT_HASH_FILE)).trim();
const doneEntries = String(fs.readFileSync(REBASE_DONE_FILE)).trim().split('\n');
const lastEntry = doneEntries[doneEntries.length - 1];
const [action, sha] = lastEntry.split(' ', 3);
if (action === 'edit') return sha;
if (action === 'exec') return 'exec';
return undefined;
}

function continueRebasing() {
Expand All @@ -230,6 +238,14 @@ function continueRebasing() {
// eslint-disable-next-line no-constant-condition
while (true) {
currentConflict = getConflictHash();
if (currentConflict === 'exec') {
if (shouldRetest()) {
console.error('To continue, first run tests with "trt exec".');
return;
}
gitContinue();
return;
}
if (!currentConflict) {
log('No conflict - done!');
if (!inRebase()) cleanupConfigDir();
Expand Down
Loading