@@ -166,7 +166,7 @@ func main() {
166166 }
167167
168168 printSuccess ("Assistant: Next tag is " + nextTag )
169- // errGuard(client, tag(nextTag))
169+ errGuard (client , tag (nextTag ))
170170 printSuccess ("Assistant: New tag " + nextTag + " created" )
171171 }
172172
@@ -285,13 +285,35 @@ func askForAutoStage(apiClient *GptClient) (bool, error) {
285285 return isAgree , nil
286286}
287287
288+ // git rev-list --tags --max-count=1
289+ func getLastTagCommitSha () (string , error ) {
290+ workingDir , err := os .Getwd ()
291+ if err != nil {
292+ return "" , err
293+ }
294+
295+ cmd := exec .Command ("git" , "rev-list" , "--tags" , "--max-count=1" )
296+ cmd .Dir = workingDir
297+ out , err := cmd .Output ()
298+ if err != nil {
299+ return "" , err
300+ }
301+
302+ return strings .TrimSpace (string (out )), nil
303+ }
304+
288305func getCurrentTag () (string , error ) {
289306 workingDir , err := os .Getwd ()
290307 if err != nil {
291308 return "" , err
292309 }
293310
294- cmd := exec .Command ("git" , "describe" , "--tags" , "--abbrev=0" )
311+ commitHash , err := getLastTagCommitSha ()
312+ if err != nil {
313+ return "" , err
314+ }
315+
316+ cmd := exec .Command ("git" , "describe" , "--tags" , commitHash )
295317 cmd .Dir = workingDir
296318 out , err := cmd .Output ()
297319 if err != nil {
0 commit comments