Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SUP-2875 | produce actionable error on missing default branch #426

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

mcncl
Copy link
Contributor

@mcncl mcncl commented Dec 30, 2024

Changes

We can check the returned value of the pipeline targeted as it's a field on the struct

if p.DefaultBranch == "" {
	actionErr = fmt.Errorf("No default branch set for pipeline %s. Please specify a branch using --branch (-b)", pipeline)
	return
}

Here we just check that the default_branch of the pipeline isn't null, if it is then we produce a helpful error to use --branch in the command, else the build will be created on the default branch for the pipeline.`

@mcncl mcncl changed the title produce actionable error on missing default branch SUP-2875 | produce actionable error on missing default branch Dec 30, 2024
@mcncl mcncl enabled auto-merge (squash) December 30, 2024 10:36
Comment on lines +148 to +151
if p.DefaultBranch == "" {
actionErr = fmt.Errorf("No default branch set for pipeline %s. Please specify a branch using --branch (-b)", pipeline)
return
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Go's way of checking that there is some value to a string, we don't care what that value is (foo is as valid as main for a default branch)

@mcncl mcncl merged commit de985b8 into main Dec 30, 2024
1 check passed
@mcncl mcncl deleted the bm/better_error_default_branch branch December 30, 2024 22:21
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