Skip to content

Commit

Permalink
SCM Graph - Add "Create Tag" action to history item context menu (#22…
Browse files Browse the repository at this point in the history
  • Loading branch information
lszomoru authored Sep 13, 2024
1 parent fa28177 commit 8a9caf3
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
9 changes: 7 additions & 2 deletions extensions/git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion extensions/git/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions extensions/git/src/api/api1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
4 changes: 2 additions & 2 deletions extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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 })
Expand Down
12 changes: 8 additions & 4 deletions extensions/git/src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions extensions/git/src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit 8a9caf3

Please sign in to comment.