diff --git a/CHANGELOG.md b/CHANGELOG.md index c343549..9339bef 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-9](https://github.com/rimi-itk/gh-itkdev/pull/9) + Added alternative base branches * [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..a9a28df 100644 --- a/cmd/changelog.go +++ b/cmd/changelog.go @@ -2,9 +2,9 @@ package cmd import ( "fmt" - "github.com/rimi-itk/gh-itkdev/changelog" "github.com/spf13/cobra" + "os/exec" ) // changelogCmd represents the changelog command @@ -16,8 +16,18 @@ 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"