Adds git.showUnpublishedCommitsButton setting

This commit is contained in:
Eric Amodio 2021-09-28 00:12:07 -04:00
parent 23fffbd7d7
commit 51bd88d8f2
3 changed files with 43 additions and 16 deletions

View file

@ -2128,6 +2128,7 @@
"deprecationMessage": "This setting is now deprecated, please use `github.gitAuthentication` instead."
},
"git.timeline.date": {
"type": "string",
"enum": [
"committed",
"authored"
@ -2145,6 +2146,22 @@
"default": true,
"description": "%config.timeline.showAuthor%",
"scope": "window"
},
"git.showUnpublishedCommitsButton": {
"type": "string",
"enum": [
"always",
"whenEmpty",
"never"
],
"enumDescriptions": [
"%config.showUnpublishedCommitsButton.always%",
"%config.showUnpublishedCommitsButton.whenEmpty%",
"%config.showUnpublishedCommitsButton.never%"
],
"default": "whenEmpty",
"description": "%config.showUnpublishedCommitsButton%",
"scope": "resource"
}
}
},

View file

@ -185,6 +185,10 @@
"config.timeline.date.committed": "Use the committed date",
"config.timeline.date.authored": "Use the authored date",
"config.useCommitInputAsStashMessage": "Controls whether to use the message from the commit input box as the default stash message.",
"config.showUnpublishedCommitsButton": "Controls whether to show an action button to sync or publish, if there are unpublished commits.",
"config.showUnpublishedCommitsButton.always": "Always shows the action button, if there are unpublished commits.",
"config.showUnpublishedCommitsButton.whenEmpty": "Only shows the action button if there are no other changes and there are unpublished commits.",
"config.showUnpublishedCommitsButton.never": "Nevers shows the action button.",
"submenu.explorer": "Git",
"submenu.commit": "Commit",
"submenu.commit.amend": "Amend",

View file

@ -917,6 +917,8 @@ export class Repository implements Disposable {
|| e.affectsConfiguration('git.untrackedChanges', root)
|| e.affectsConfiguration('git.ignoreSubmodules', root)
|| e.affectsConfiguration('git.openDiffOnClick', root)
|| e.affectsConfiguration('git.rebaseWhenSync', root)
|| e.affectsConfiguration('git.showUnpublishedCommitsButton', root)
)(this.updateModelState, this, this.disposables);
const updateInputBoxVisibility = () => {
@ -1907,27 +1909,31 @@ export class Repository implements Disposable {
});
let actionButton: SourceControl['actionButton'];
if (HEAD !== undefined && workingTree.length === 0 && index.length === 0 && untracked.length === 0 && merge.length === 0) {
if (HEAD.name && HEAD.commit) {
if (HEAD.upstream) {
if (HEAD.ahead) {
const config = workspace.getConfiguration('git', Uri.file(this.repository.root));
const rebaseWhenSync = config.get<string>('rebaseWhenSync');
if (HEAD !== undefined) {
const config = workspace.getConfiguration('git', Uri.file(this.repository.root));
const showActionButton = config.get<string>('showUnpublishedCommitsButton', 'whenEmpty');
if (showActionButton === 'always' || (showActionButton === 'whenEmpty' && workingTree.length === 0 && index.length === 0 && untracked.length === 0 && merge.length === 0)) {
if (HEAD.name && HEAD.commit) {
if (HEAD.upstream) {
if (HEAD.ahead) {
const rebaseWhenSync = config.get<string>('rebaseWhenSync');
actionButton = {
command: rebaseWhenSync ? 'git.syncRebase' : 'git.sync',
title: localize('scm button sync title', ' Sync Changes \u00a0$(sync){0}{1}', HEAD.behind ? `${HEAD.behind}$(arrow-down) ` : '', `${HEAD.ahead}$(arrow-up)`),
tooltip: this.syncTooltip,
arguments: [this._sourceControl],
};
}
} else {
actionButton = {
command: rebaseWhenSync ? 'git.syncRebase' : 'git.sync',
title: localize('scm button sync title', ' Sync Changes \u00a0$(sync){0}{1}', HEAD.behind ? `${HEAD.behind}$(arrow-down) ` : '', `${HEAD.ahead}$(arrow-up)`),
tooltip: this.syncTooltip,
command: 'git.publish',
title: localize('scm button publish title', "$(cloud-upload) Publish Changes"),
tooltip: localize('scm button publish tooltip', "Publish Changes"),
arguments: [this._sourceControl],
};
}
} else {
actionButton = {
command: 'git.publish',
title: localize('scm button publish title', "$(cloud-upload) Publish Changes"),
tooltip: localize('scm button publish tooltip', "Publish Changes"),
arguments: [this._sourceControl],
};
}
}
}