fix(maven): skip pom.xml update when file does not exist
ci / vet, staticcheck, test, build (push) Successful in 3m3s
release / Build and publish release (push) Successful in 4m10s

If pom.xml (or the configured maven.pom_path) is absent, releaser now
logs a notice and proceeds to tag and push without failing. This makes
the tool usable in non-Maven projects. An os.Stat error that is not
ErrNotExist (e.g. permission denied) still surfaces as an error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-07 00:33:57 +02:00
parent c92164eb37
commit 7fdf5ddcf3
4 changed files with 47 additions and 9 deletions
+11 -3
View File
@@ -203,9 +203,15 @@ func run(o options) error {
return nil
}
// --- pom.xml (skipped with --tag-only) ---
if !o.tagOnly {
pomPath := filepath.Join(absRepo, cfg.Maven.PomPath)
// --- pom.xml (skipped with --tag-only or when the file does not exist) ---
pomPath := filepath.Join(absRepo, cfg.Maven.PomPath)
_, statErr := os.Stat(pomPath)
hasPom := !errors.Is(statErr, os.ErrNotExist)
if statErr != nil && hasPom {
return fmt.Errorf("check pom path: %w", statErr)
}
if !o.tagOnly && hasPom {
currentPomVersion, err := maven.ReadVersion(pomPath)
if err != nil {
return fmt.Errorf("read pom version: %w", err)
@@ -235,6 +241,8 @@ func run(o options) error {
return fmt.Errorf("commit pom.xml: %w", err)
}
fmt.Fprintf(os.Stderr, "info: committed: %s\n", commitMsg)
} else if !o.tagOnly && !hasPom {
fmt.Fprintln(os.Stderr, "info: no pom.xml found — skipping version bump commit")
}
// --- Git tag ---