Bladeren bron

Fixes #2292 force-push to non-current branch

main
Nafiur Rahman Khadem 2 jaren geleden
committed by Eric Amodio
bovenliggende
commit
660c79ed3a
4 gewijzigde bestanden met toevoegingen van 23 en 36 verwijderingen
  1. +1
    -0
      CHANGELOG.md
  2. +15
    -21
      src/commands/git/push.ts
  3. +6
    -14
      src/git/models/repository.ts
  4. +1
    -1
      src/views/viewCommands.ts

+ 1
- 0
CHANGELOG.md Bestand weergeven

@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#2292](https://github.com/gitkraken/vscode-gitlens/issues/2292) - Push button in BranchTrackingStatusNode of non-current branch does not trigger "Push force"
- Fixes [#1488](https://github.com/gitkraken/vscode-gitlens/issues/1488) - Open Folder History not working with non-English language pack
- Fixes [#2303](https://github.com/gitkraken/vscode-gitlens/issues/2303) - "Googlesource" gerrit only supports two levels of domain — thanks to [PR #2304](https://github.com/gitkraken/vscode-gitlens/pull/2304) by Matt Buckley ([@Mattadore](https://github.com/Mattadore))
- Fixes [#2300](https://github.com/gitkraken/vscode-gitlens/issues/2300) - extra non-functional toolbar buttons when viewing PR diffs in VSCode web

+ 15
- 21
src/commands/git/push.ts Bestand weergeven

@ -226,29 +226,23 @@ export class PushGitCommand extends QuickCommand {
);
}
} else if (branch != null && branch?.state.behind > 0) {
const currentBranch = await repo.getBranch();
step = this.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
branch.id === currentBranch?.id
? [
FlagsQuickPickItem.create<Flags>(state.flags, ['--force'], {
label: `Force ${this.title}${useForceWithLease ? ' (with lease)' : ''}`,
description: `--force${useForceWithLease ? '-with-lease' : ''}`,
detail: `Will force push${useForceWithLease ? ' (with lease)' : ''} ${
branch?.state.ahead ? ` ${pluralize('commit', branch.state.ahead)}` : ''
}${branch.getRemoteName() ? ` to ${branch.getRemoteName()}` : ''}${
branch != null && branch.state.behind > 0
? `, overwriting ${pluralize('commit', branch.state.behind)}${
branch?.getRemoteName()
? ` on ${branch.getRemoteName()}`
: ''
}`
: ''
}`,
}),
]
: [],
[
FlagsQuickPickItem.create<Flags>(state.flags, ['--force'], {
label: `Force ${this.title}${useForceWithLease ? ' (with lease)' : ''}`,
description: `--force${useForceWithLease ? '-with-lease' : ''}`,
detail: `Will force push${useForceWithLease ? ' (with lease)' : ''} ${
branch?.state.ahead ? ` ${pluralize('commit', branch.state.ahead)}` : ''
}${branch.getRemoteName() ? ` to ${branch.getRemoteName()}` : ''}${
branch != null && branch.state.behind > 0
? `, overwriting ${pluralize('commit', branch.state.behind)}${
branch?.getRemoteName() ? ` on ${branch.getRemoteName()}` : ''
}`
: ''
}`,
}),
],
DirectiveQuickPickItem.create(Directive.Cancel, true, {
label: `Cancel ${this.title}`,
detail: `Cannot push; ${GitReference.toString(

+ 6
- 14
src/git/models/repository.ts Bestand weergeven

@ -764,20 +764,12 @@ export class Repository implements Disposable {
const branch = await this.getBranch(options?.reference.name);
if (branch == null) return;
const currentBranch = await this.getBranch();
if (branch.id === currentBranch?.id) {
void (await executeCoreGitCommand(
options?.force ? CoreGitCommands.PushForce : CoreGitCommands.Push,
this.path,
));
} else {
await repo?.push(
branch.getRemoteName(),
branch.name,
undefined,
options?.force ? ForcePushMode.ForceWithLease : undefined,
);
}
await repo?.push(
branch.getRemoteName(),
branch.name,
undefined,
options?.force ? ForcePushMode.ForceWithLease : undefined,
);
}
} else if (options?.reference != null) {
const repo = await this.container.git.getOrOpenScmRepository(this.path);

+ 1
- 1
src/views/viewCommands.ts Bestand weergeven

@ -616,7 +616,7 @@ export class ViewCommands {
}
if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) {
return GitActions.push(node.repoPath, undefined, node.root ? undefined : node.branch);
return GitActions.push(node.repoPath, force, node.root ? undefined : node.branch);
}
if (node instanceof CommitNode || node instanceof FileRevisionAsCommitNode) {

Laden…
Annuleren
Opslaan