From 4254328fabd9ac71cea58daa4b596b4f085adba0 Mon Sep 17 00:00:00 2001 From: Kipras Melnikovas Date: Tue, 29 Mar 2022 14:26:09 +0300 Subject: [PATCH 1/2] feat: use --force-with-lease instead of --force Signed-off-by: Kipras Melnikovas --- forcePush.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/forcePush.ts b/forcePush.ts index 86fb0e83..c35ecf1d 100644 --- a/forcePush.ts +++ b/forcePush.ts @@ -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(); @@ -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, From 99d529bbe79403099c4482ee13d4120b2e8c7a1c Mon Sep 17 00:00:00 2001 From: Kipras Melnikovas Date: Thu, 31 Mar 2022 01:36:17 +0300 Subject: [PATCH 2/2] use --force-if-inclues alongside --force-with-lease Signed-off-by: Kipras Melnikovas --- forcePush.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/forcePush.ts b/forcePush.ts index c35ecf1d..c8d6b0e1 100644 --- a/forcePush.ts +++ b/forcePush.ts @@ -58,8 +58,13 @@ export const forcePush: BranchSequencerBase = (argsBase) => * * needs to be further explored with our `--sync` (TBD) * + * + * on --force-if-includes, see: + * - `man git-push` + * - https://stackoverflow.com/a/65839129/9285308 + * - https://github.com/gitextensions/gitextensions/issues/8753#issuecomment-763390579 */ - const forceWithLeaseOrForce: string = "--force-with-lease"; + const forceWithLeaseOrForce: string = "--force-with-lease --force-if-includes"; if (!upstreamBranch) { const remotes: string[] = await repo.getRemoteNames();