SCM Graph - Add "Create Tag" action to history item context menu (#228428)

This commit is contained in:
Ladislau Szomoru 2024-09-13 10:17:44 +02:00 committed by GitHub
parent fa28177248
commit 8a9caf323a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 22 additions and 13 deletions

View file

@ -1943,15 +1943,20 @@
}
],
"scm/historyItem/context": [
{
"command": "git.createTag",
"when": "scmProvider == git",
"group": "1_create@1"
},
{
"command": "git.copyCommitId",
"when": "scmProvider == git && !listMultiSelection",
"group": "1_copy@1"
"group": "9_copy@1"
},
{
"command": "git.copyCommitMessage",
"when": "scmProvider == git && !listMultiSelection",
"group": "1_copy@2"
"group": "9_copy@2"
}
],
"editor/title": [

View file

@ -70,7 +70,7 @@
"command.merge": "Merge...",
"command.mergeAbort": "Abort Merge",
"command.rebase": "Rebase Branch...",
"command.createTag": "Create Tag",
"command.createTag": "Create Tag...",
"command.deleteTag": "Delete Tag...",
"command.deleteRemoteTag": "Delete Remote Tag...",
"command.fetch": "Fetch",

View file

@ -201,8 +201,8 @@ export class ApiRepository implements Repository {
return this.repository.getMergeBase(ref1, ref2);
}
tag(name: string, upstream: string): Promise<void> {
return this.repository.tag(name, upstream);
tag(name: string, message: string, ref?: string | undefined): Promise<void> {
return this.repository.tag({ name, message, ref });
}
deleteTag(name: string): Promise<void> {

View file

@ -2907,7 +2907,7 @@ export class CommandCenter {
}
@command('git.createTag', { repository: true })
async createTag(repository: Repository): Promise<void> {
async createTag(repository: Repository, historyItem?: SourceControlHistoryItem): Promise<void> {
const inputTagName = await window.showInputBox({
placeHolder: l10n.t('Tag name'),
prompt: l10n.t('Please provide a tag name'),
@ -2925,7 +2925,7 @@ export class CommandCenter {
});
const name = inputTagName.replace(/^\.|\/\.|\.\.|~|\^|:|\/$|\.lock$|\.lock\/|\\|\*|\s|^\s*$|\.$/g, '-');
await repository.tag(name, inputMessage);
await repository.tag({ name, message: inputMessage, ref: historyItem?.id });
}
@command('git.deleteTag', { repository: true })

View file

@ -1807,13 +1807,17 @@ export class Repository {
await this.exec(['merge', '--abort']);
}
async tag(name: string, message?: string): Promise<void> {
async tag(options: { name: string; message?: string; ref?: string }): Promise<void> {
let args = ['tag'];
if (message) {
args = [...args, '-a', name, '-m', message];
if (options.message) {
args = [...args, '-a', options.name, '-m', options.message];
} else {
args = [...args, name];
args = [...args, options.name];
}
if (options.ref) {
args.push(options.ref);
}
await this.exec(args);

View file

@ -1563,8 +1563,8 @@ export class Repository implements Disposable {
await this.run(Operation.Rebase, () => this.repository.rebase(branch));
}
async tag(name: string, message?: string): Promise<void> {
await this.run(Operation.Tag, () => this.repository.tag(name, message));
async tag(options: { name: string; message?: string; ref?: string }): Promise<void> {
await this.run(Operation.Tag, () => this.repository.tag(options));
}
async deleteTag(name: string): Promise<void> {