Selaa lähdekoodia

Fixes force push of current branch

main
Eric Amodio 4 vuotta sitten
vanhempi
commit
60d35b8a79
3 muutettua tiedostoa jossa 33 lisäystä ja 16 poistoa
  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 Näytä tiedosto

@ -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 Näytä tiedosto

@ -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 Näytä tiedosto

@ -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);

Ladataan…
Peruuta
Tallenna