diff --git a/CHANGELOG.md b/CHANGELOG.md index c343549..5342655 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +* [PR-10](https://github.com/rimi-itk/gh-itkdev/pull/10) + Added release base branch detection * [PR-7](https://github.com/rimi-itk/gh-itkdev/pull/7) Fixed URL parsing diff --git a/cmd/changelog.go b/cmd/changelog.go index f7dbb87..0296ac2 100644 --- a/cmd/changelog.go +++ b/cmd/changelog.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "os/exec" "github.com/rimi-itk/gh-itkdev/changelog" "github.com/spf13/cobra" @@ -16,8 +17,19 @@ var ( {{ .Title }}` release string - baseBranch string = "develop" - commit bool = false + baseBranch string = func() string { + branches := []string{"develop", "main", "master"} + for _, branch := range branches { + cmd := exec.Command("git", "rev-parse", "--verify", "--branch", branch) + if _, err := cmd.CombinedOutput(); err == nil { + return branch + } + } + + // Fallback if no other suitable branch is found. + return branches[0] + }() + commit bool = false changelogName string = "CHANGELOG.md"