Last active
September 22, 2022 17:26
-
-
Save jniltinho/0f941373da4b59b51c0150b4f7c35613 to your computer and use it in GitHub Desktop.
Regex Jira ID Golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// go mod init get-jira-id | |
// gofmt -w main.go | |
// go build -ldflags="-s -w" | |
// upx --best --lzma get-jira-id | |
// ./get-jira-id --issue=feature/Pbo-784-epic | |
import ( | |
"flag" | |
"os" | |
"regexp" | |
"strings" | |
) | |
func main() { | |
issueID := flag.String("issue", "feature/PBO-5599-epic", "Issue ID name") | |
flag.Parse() | |
GetIssueID(*issueID) | |
//GetIssueID("fc/PBO-559999-epic-NNNN-VVVGGG") | |
} | |
func GetIssueID(issueIDName string) { | |
re := regexp.MustCompile(`(\b(pbo|asd|asdp|ae|at))+-[\d]+`) | |
matches := re.FindAllString(strings.ToLower(issueIDName), -1) | |
if len(matches) == 0 { | |
print("not_found_jira_id") | |
os.Exit(1) | |
} | |
print(matches[0]) | |
os.Exit(0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment