Skip to content

Update pr.go to check if .Type is empty to avoid trying to create an empty label #18

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dougnukem
Copy link

Description

When creating a branch pattern where {{.Type}} is optional gh prx fails to create label with error:

⨯ Command failed                                     error=Failed to create labels: Failed to create label '': failed to run gh: HTTP 422: Validation Failed (https://api.github.com/repos/customerOrg/repoTest/labels)
branch:
   template: "{{.Type}}/{{with .Issue}}{{.}}-{{end}}{{.Description}}" # Branch name template
   pattern: "({{.Type}}|{{.Prefix}})\\/({{.Issue}}-)?{{.Description}}" # Branch name pattern
   variable_patterns: # A map of patterns to match for each template variable
      Type: "fix|feat|chore|docs|refactor|test|style|build|ci|perf|revert"
      # Branch name prefix like dougnukem/JIRAPROJ-XYZ-description-stuff
      Prefix: "[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*"
      Issue: "([a-zA-Z]+\\-)*[0-9]+"
      Author: "[a-zA-Z0-9]+"
      Description: ".*"
   token_separators: ["-", "_"] # Characters used to separate branch name into a human-readable string
   max_length: 60 # Max characters to allow for branch length without prompting for changing it

@ilaif ilaif self-requested a review April 22, 2024 14:56
Copy link
Owner

@ilaif ilaif left a comment

Choose a reason for hiding this comment

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

Thanks for fixing that! LGTM

@ilaif
Copy link
Owner

ilaif commented Apr 22, 2024

@dougnukem there's a new linter I added that handles complexity in if blocks. It might be too sensitive but you can try refactor to a guard-clause to remove the complexity.

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