Skip to content

Comments

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

Open
dougnukem wants to merge 2 commits intoilaif:mainfrom
dougnukem:patch-1
Open

Update pr.go to check if .Type is empty to avoid trying to create an empty label#18
dougnukem wants to merge 2 commits intoilaif:mainfrom
dougnukem:patch-1

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