addons/isl/src/operations/AbortMergeOperation.tsblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318import type {MergeConflicts} from '../types';
b69ab319
b69ab3110import {Operation} from './Operation';
b69ab3111
b69ab3112export class AbortMergeOperation extends Operation {
b69ab3113 constructor(
b69ab3114 private conflicts: MergeConflicts,
b69ab3115 private isPartialAbort: boolean,
b69ab3116 ) {
b69ab3117 super('AbortMergeOperation');
b69ab3118 }
b69ab3119
b69ab3120 static opName = 'Abort';
b69ab3121
b69ab3122 // `sl abort` isn't a real command like `sl continue` is.
b69ab3123 // however, the merge conflict data we've fetched includes the command to abort
b69ab3124 getArgs() {
b69ab3125 if (this.isPartialAbort) {
b69ab3126 // only rebase supports partial aborts
b69ab3127 return ['rebase', '--quit'];
b69ab3128 }
b69ab3129 if (this.conflicts.toAbort == null) {
b69ab3130 // if conflicts are still loading we don't know the right command...
b69ab3131 // just try `rebase --abort`...
b69ab3132 return ['rebase', '--abort'];
b69ab3133 }
b69ab3134 return this.conflicts.toAbort.split(' ');
b69ab3135 }
b69ab3136
b69ab3137 // It's tempting to add makeOptimisticMergeConflictsApplier to `abort`,
b69ab3138 // but hiding optimistic conflicts may reveal temporary uncommitted changes
b69ab3139 // we could use optimistic uncommitted changes to hide those as well,
b69ab3140 // but it gets complicated. More robust is to just show a spinner on the abort button instead.
b69ab3141 // Abort should be relatively quick.
b69ab3142 // TODO: if this is a slow point in workflows, we could make this experience smoother.
b69ab3143}