Skip to content

Commit f53eba8

Browse files
committed
feat: use --force-with-lease instead of --force
Signed-off-by: Kipras Melnikovas <[email protected]>
1 parent b66fe22 commit f53eba8

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Diff for: forcePush.ts

+19-2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ export const forcePush: BranchSequencerBase = (argsBase) =>
4444
const branch: Git.Reference = await repo.getCurrentBranch();
4545
const upstreamBranch: Git.Reference | null = await Git.Branch.upstream(branch).catch(() => null);
4646

47+
/**
48+
* TODO work out a good solution because we don't want the user
49+
* to get interrupted while in-between the "push" flow,
50+
* or at least handle it ourselves / ask the user how to continue
51+
*
52+
* maybe need to have a `--push --continue`?
53+
* ugh, starts to get mixed up w/ other commands, idk!
54+
* or could `--continue` be used in any circumstance,
55+
* i.e. both in a rebase setting, and in a push setting?
56+
*
57+
* could maybe utilize --dry-run? or analyze ourselves? idk
58+
*
59+
* needs to be further explored with our `--sync` (TBD)
60+
*
61+
*/
62+
const forceWithLeaseOrForce: string = "--force-with-lease";
63+
4764
if (!upstreamBranch) {
4865
const remotes: string[] = await repo.getRemoteNames();
4966

@@ -85,11 +102,11 @@ export const forcePush: BranchSequencerBase = (argsBase) =>
85102
remote = answer;
86103
}
87104

88-
const cmd = `push -u ${remote} ${branch.name()} --force`;
105+
const cmd = `push -u ${remote} ${branch.name()} ${forceWithLeaseOrForce}`;
89106
console.log(`running ${cmd}`);
90107
execSyncInRepo(`${argsBase.gitCmd} ${cmd}`);
91108
} else {
92-
execSyncInRepo(`${argsBase.gitCmd} push --force`);
109+
execSyncInRepo(`${argsBase.gitCmd} push ${forceWithLeaseOrForce}`);
93110
}
94111
},
95112
delayMsBetweenCheckouts: 0,

0 commit comments

Comments
 (0)