Parcourir la source

Fixes force push of current branch

main
Eric Amodio il y a 4 ans
Parent
révision
60d35b8a79
3 fichiers modifiés avec 33 ajouts et 16 suppressions
  1. +1
    -0
      CHANGELOG.md
  2. +26
    -15
      src/commands/git/push.ts
  3. +6
    -1
      src/git/models/repository.ts

+ 1
- 0
CHANGELOG.md Voir le fichier

@ -28,6 +28,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Fixes [#1202](https://github.com/eamodio/vscode-gitlens/issues/1202) - "Copy Remote File Url" url-encodes the URL
- Fixes an issue where _GitLens: Show Repositories View_ command wouldn't work unless the view was enabled first
- Fixes an issue where _GitLens: Show Line History View_ command wasn't showing up unless the view was enabled first
- Fixes an issue where trying to force push the current branch would fail
## [11.0.6] - 2020-11.28

+ 26
- 15
src/commands/git/push.ts Voir le fichier

@ -218,23 +218,34 @@ 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),
[
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 ? ` ${Strings.pluralize('commit', branch.state.ahead)}` : ''
}${branch.getRemoteName() ? ` to ${branch.getRemoteName()}` : ''}${
branch != null && branch.state.behind > 0
? `, overwriting ${Strings.pluralize('commit', branch.state.behind)}${
branch?.getRemoteName() ? ` on ${branch.getRemoteName()}` : ''
}`
: ''
}`,
}),
],
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
? ` ${Strings.pluralize('commit', branch.state.ahead)}`
: ''
}${branch.getRemoteName() ? ` to ${branch.getRemoteName()}` : ''}${
branch != null && branch.state.behind > 0
? `, overwriting ${Strings.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
- 1
src/git/models/repository.ts Voir le fichier

@ -584,7 +584,12 @@ export class Repository implements Disposable {
const branch = await this.getBranch(options.reference.name);
if (branch == null) return;
await repo?.push(branch.getRemoteName(), branch.name);
const currentBranch = await this.getBranch();
if (branch.id === currentBranch?.id) {
void (await commands.executeCommand(options.force ? 'git.pushForce' : 'git.push', this.path));
} else {
await repo?.push(branch.getRemoteName(), branch.name);
}
}
} else if (options.reference != null) {
const repo = await GitService.getBuiltInGitRepository(this.path);

Chargement…
Annuler
Enregistrer