@@ -6,7 +6,7 @@ import * as vscode from 'vscode';
66import { AskpassEnvironment , AskpassManager } from './askpass/askpassManager' ;
77import { getConfig } from './config' ;
88import { Logger } from './logger' ;
9- import { CommitOrdering , DateType , DeepWriteable , ErrorInfo , GitCommit , GitCommitDetails , GitCommitStash , GitConfigLocation , GitFileChange , GitFileStatus , GitPushBranchMode , GitRepoConfig , GitRepoConfigBranches , GitResetMode , GitSignatureStatus , GitStash , MergeActionOn , RebaseActionOn , SquashMessageFormat , Writeable } from './types' ;
9+ import { CommitOrdering , DateType , DeepWriteable , ErrorInfo , GitCommit , GitCommitDetails , GitCommitStash , GitConfigLocation , GitFileChange , GitFileStatus , GitPushBranchMode , GitRepoConfig , GitRepoConfigBranches , GitResetMode , GitSignatureStatus , GitStash , MergeActionOn , RebaseActionOn , SquashMessageFormat , TagType , Writeable } from './types' ;
1010import { GitExecutable , UNABLE_TO_FIND_GIT_MSG , UNCOMMITTED , abbrevCommit , constructIncompatibleGitVersionMessage , getPathFromStr , getPathFromUri , isGitAtLeastVersion , openGitTerminal , pathWithTrailingSlash , realpath , resolveSpawnOutput } from './utils' ;
1111import { Disposable } from './utils/disposable' ;
1212import { Event } from './utils/event' ;
@@ -257,9 +257,15 @@ export class DataSource extends Disposable {
257257 }
258258 }
259259
260- return { commits : commitNodes , head : refData . head , moreCommitsAvailable : moreCommitsAvailable , error : null } ;
260+ return {
261+ commits : commitNodes ,
262+ head : refData . head ,
263+ tags : unique ( refData . tags . map ( ( tag ) => tag . name ) ) ,
264+ moreCommitsAvailable : moreCommitsAvailable ,
265+ error : null
266+ } ;
261267 } ) . catch ( ( errorMessage ) => {
262- return { commits : [ ] , head : null , moreCommitsAvailable : false , error : errorMessage } ;
268+ return { commits : [ ] , head : null , tags : [ ] , moreCommitsAvailable : false , error : errorMessage } ;
263269 } ) ;
264270 }
265271
@@ -659,13 +665,17 @@ export class DataSource extends Disposable {
659665 * @param repo The path of the repository.
660666 * @param tagName The name of the tag.
661667 * @param commitHash The hash of the commit the tag should be added to.
662- * @param lightweight Is the tag lightweight.
668+ * @param type Is the tag annotated or lightweight.
663669 * @param message The message of the tag (if it is an annotated tag).
670+ * @param force Force add the tag, replacing an existing tag with the same name (if it exists).
664671 * @returns The ErrorInfo from the executed command.
665672 */
666- public addTag ( repo : string , tagName : string , commitHash : string , lightweight : boolean , message : string ) {
673+ public addTag ( repo : string , tagName : string , commitHash : string , type : TagType , message : string , force : boolean ) {
667674 const args = [ 'tag' ] ;
668- if ( lightweight ) {
675+ if ( force ) {
676+ args . push ( '-f' ) ;
677+ }
678+ if ( type === TagType . Lightweight ) {
669679 args . push ( tagName ) ;
670680 } else {
671681 args . push ( getConfig ( ) . signTags ? '-s' : '-a' , tagName , '-m' , message ) ;
@@ -1783,6 +1793,12 @@ function removeTrailingBlankLines(lines: string[]) {
17831793 return lines ;
17841794}
17851795
1796+ function unique ( items : ReadonlyArray < string > ) {
1797+ const uniqueItems : { [ item : string ] : true } = { } ;
1798+ items . forEach ( ( item ) => uniqueItems [ item ] = true ) ;
1799+ return Object . keys ( uniqueItems ) ;
1800+ }
1801+
17861802
17871803/* Types */
17881804
@@ -1816,6 +1832,7 @@ interface GitCommitRecord {
18161832interface GitCommitData {
18171833 commits : GitCommit [ ] ;
18181834 head : string | null ;
1835+ tags : string [ ] ;
18191836 moreCommitsAvailable : boolean ;
18201837 error : ErrorInfo ;
18211838}
0 commit comments