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
6 changed files with 22 additions and 13 deletions

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> {