Skip to content

Commit

Permalink
feat: use --force-with-lease instead of --force
Browse files Browse the repository at this point in the history
Signed-off-by: Kipras Melnikovas <[email protected]>
  • Loading branch information
kiprasmel committed Apr 12, 2022
1 parent 373e889 commit ba19fd6
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions forcePush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ export const forcePush: BranchSequencerBase = (argsBase) =>
const branch: Git.Reference = await repo.getCurrentBranch();
const upstreamBranch: Git.Reference | null = await Git.Branch.upstream(branch).catch(() => null);

/**
* TODO work out a good solution because we don't want the user
* to get interrupted while in-between the "push" flow,
* or at least handle it ourselves / ask the user how to continue
*
* maybe need to have a `--push --continue`?
* ugh, starts to get mixed up w/ other commands, idk!
* or could `--continue` be used in any circumstance,
* i.e. both in a rebase setting, and in a push setting?
*
* could maybe utilize --dry-run? or analyze ourselves? idk
*
* needs to be further explored with our `--sync` (TBD)
*
*/
const forceWithLeaseOrForce: string = "--force-with-lease";

if (!upstreamBranch) {
const remotes: string[] = await repo.getRemoteNames();

Expand Down Expand Up @@ -85,11 +102,11 @@ export const forcePush: BranchSequencerBase = (argsBase) =>
remote = answer;
}

const cmd = `push -u ${remote} ${branch.name()} --force`;
const cmd = `push -u ${remote} ${branch.name()} ${forceWithLeaseOrForce}`;
console.log(`running ${cmd}`);
execSyncInRepo(`${argsBase.gitCmd} ${cmd}`);
} else {
execSyncInRepo(`${argsBase.gitCmd} push --force`);
execSyncInRepo(`${argsBase.gitCmd} push ${forceWithLeaseOrForce}`);
}
},
delayMsBetweenCheckouts: 0,
Expand Down

0 comments on commit ba19fd6

Please sign in to comment.