Skip to content

Conversation

jeppekroghitk
Copy link
Collaborator

@jeppekroghitk jeppekroghitk commented Sep 16, 2024

I ran into a project where "main" were the main branch. Since "develop" is the only predefined base branch, the release script did not work. I added an array of base branches, defined as ["develop", "main", "master"], to increase the success rate of the release script.

Apologies in advance - AI aided me with these changes, as i have yet to learn GO.

  • Updated baseBranch from string to array of strings
  • Updated release script to handle array of base branches and try each one

@rimi-itk
Copy link
Collaborator

Great idea!

We need to make sure that users can (also) override the base branch, so something along the lines of

	baseBranch string = func() string {
		branches := []string{"develop", "main", "master"}
		for _, branch := range branches {
			cmd := exec.Command("git", "rev-parse", "--verify", "-b", branch)
			if _, err := cmd.CombinedOutput(); err == nil {
				return branch
			}
		}

		// Fallback if no other suitable branch is found.
		return branches[0]
	}()

may be a better approach, i.e. digging for a sane default branch.

@jeppekroghitk
Copy link
Collaborator Author

@rimi-itk Donno

@rimi-itk rimi-itk merged commit e6330f1 into main Nov 5, 2024
8 checks passed
@rimi-itk rimi-itk deleted the feature/add-main-as-alternative branch November 5, 2024 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants