Skip to content

Commit e6330f1

Browse files
authored
Merge pull request #9 from rimi-itk/feature/add-main-as-alternative
Feature: Add alternative base branches
2 parents 9eaed86 + bd6753a commit e6330f1

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
* [PR-9](https://github.com/rimi-itk/gh-itkdev/pull/9)
11+
Added alternative base branches
1012
* [PR-7](https://github.com/rimi-itk/gh-itkdev/pull/7)
1113
Fixed URL parsing
1214

cmd/changelog.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package cmd
22

33
import (
44
"fmt"
5-
65
"github.com/rimi-itk/gh-itkdev/changelog"
76
"github.com/spf13/cobra"
7+
"os/exec"
88
)
99

1010
// changelogCmd represents the changelog command
@@ -16,8 +16,18 @@ var (
1616
{{ .Title }}`
1717

1818
release string
19-
baseBranch string = "develop"
20-
commit bool = false
19+
baseBranch string = func() string {
20+
branches := []string{"develop", "main", "master"}
21+
for _, branch := range branches {
22+
cmd := exec.Command("git", "rev-parse", "--verify", "--branch", branch)
23+
if _, err := cmd.CombinedOutput(); err == nil {
24+
return branch
25+
}
26+
}
27+
// Fallback if no other suitable branch is found.
28+
return branches[0]
29+
}()
30+
commit bool = false
2131

2232
changelogName string = "CHANGELOG.md"
2333

0 commit comments

Comments
 (0)