@@ -246,7 +246,6 @@ func (p *Parser) ParseHistory(commits []*object.Commit, latestSemver *semver.Ver
246
246
}
247
247
248
248
releaseType , ok := rulesMap [commitType ]
249
-
250
249
if ! ok {
251
250
continue
252
251
}
@@ -273,6 +272,7 @@ func (p *Parser) ParseHistory(commits []*object.Commit, latestSemver *semver.Ver
273
272
// among all tags.
274
273
func (p * Parser ) FetchLatestSemverTag (repository * git.Repository , project monorepo.Project ) (* object.Tag , error ) {
275
274
p .mu .Lock ()
275
+ defer p .mu .Unlock ()
276
276
277
277
tags , err := repository .TagObjects ()
278
278
if err != nil {
@@ -289,15 +289,8 @@ func (p *Parser) FetchLatestSemverTag(repository *git.Repository, project monore
289
289
return nil
290
290
}
291
291
292
- if project .Name != "" {
293
- matchProjectTagFormat , err := regexp .MatchString (fmt .Sprintf (`^%s\-.*` , project .Name ), tag .Name )
294
- if err != nil {
295
- return err
296
- }
297
-
298
- if ! matchProjectTagFormat {
299
- return nil
300
- }
292
+ if project .Name != "" && ! strings .HasPrefix (tag .Name , project .Name + "-" ) {
293
+ return nil
301
294
}
302
295
303
296
currentSemver , err := semver .NewFromString (tag .Name )
@@ -311,11 +304,11 @@ func (p *Parser) FetchLatestSemverTag(repository *git.Repository, project monore
311
304
}
312
305
return nil
313
306
})
307
+
314
308
if err != nil {
315
309
return nil , fmt .Errorf ("looping over tags: %w" , err )
316
310
}
317
311
318
- p .mu .Unlock ()
319
312
return latestTag , nil
320
313
}
321
314
@@ -350,25 +343,16 @@ func (p *Parser) checkoutBranch(repository *git.Repository) error {
350
343
// commitContainsProjectFiles checks if a given commit changes contain at least one file whose path belongs to the
351
344
// given project's path.
352
345
func commitContainsProjectFiles (commit * object.Commit , projectPath string ) (bool , error ) {
353
- regex , err := regexp .Compile (fmt .Sprintf ("^%s" , projectPath ))
354
- if err != nil {
355
- return false , fmt .Errorf ("compiling project's path regexp: %w" , err )
356
- }
357
-
358
346
commitTree , err := commit .Tree ()
359
347
if err != nil {
360
348
return false , fmt .Errorf ("getting commit tree: %w" , err )
361
349
}
362
350
363
- parentCommit := commit .Parents ()
364
- parentTree := & object.Tree {}
365
- if parentCommit != nil {
366
- parent , err := parentCommit .Next ()
367
- if err == nil {
368
- parentTree , err = parent .Tree ()
369
- if err != nil {
370
- return false , fmt .Errorf ("getting parent tree: %w" , err )
371
- }
351
+ var parentTree * object.Tree
352
+ if parent , err := commit .Parent (0 ); err == nil {
353
+ parentTree , err = parent .Tree ()
354
+ if err != nil {
355
+ return false , fmt .Errorf ("getting parent tree: %w" , err )
372
356
}
373
357
}
374
358
@@ -378,7 +362,8 @@ func commitContainsProjectFiles(commit *object.Commit, projectPath string) (bool
378
362
}
379
363
380
364
for _ , change := range changes {
381
- if regex .MatchString (filepath .Dir (change .To .Name )) {
365
+ dir := filepath .Dir (change .To .Name )
366
+ if strings .HasPrefix (dir , projectPath ) {
382
367
return true , nil
383
368
}
384
369
}
0 commit comments