@@ -189,6 +189,7 @@ async function main(): Promise<void> {
189189 command : { short : "c" , type : "string" } ,
190190 replace : { short : "r" , type : "string" , multiple : true } ,
191191 message : { short : "m" , type : "string" , multiple : true } ,
192+ tagsort : { short : "t" , type : "string" } ,
192193 } ,
193194 } ) ;
194195 const args = result . values ;
@@ -213,6 +214,8 @@ async function main(): Promise<void> {
213214 -r, --replace <str> Additional replacements in the format "s#regexp#replacement#flags"
214215 -g, --gitless Do not perform any git action like creating commit and tag
215216 -D, --dry Do not create a tag or commit, just print what would be done
217+ -t, --tagsort How to determine base version from git tags, either "highest" or "latest".
218+ Default is "highest".
216219 -v, --version Print the version
217220 -h, --help Print this help
218221
@@ -240,7 +243,8 @@ async function main(): Promise<void> {
240243 if ( args . gitless ) return exit ( new Error ( `--gitless requires --base to be set` ) ) ;
241244 let stdout : string = "" ;
242245 try {
243- ( { stdout} = await nanoSpawn ( "git" , [ "tag" , "--list" , "--sort=-creatordate" ] ) ) ;
246+ const sort = args . tagsort === "latest" ? "-creatordate" : "-version:refname" ;
247+ ( { stdout} = await nanoSpawn ( "git" , [ "tag" , "--list" , `--sort=${ sort } ` ] ) ) ;
244248 } catch { }
245249 for ( const tag of stdout . split ( / \r ? \n / ) . map ( v => v . trim ( ) ) . filter ( Boolean ) ) {
246250 if ( isSemver ( tag ) ) {
0 commit comments