Skip to content

Commit

Permalink
Allow case-insensitive environment
Browse files Browse the repository at this point in the history
  • Loading branch information
nicanor-romero committed Jun 6, 2024
1 parent adfa174 commit 7c66ff0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ func buildCommit() (commit Commit) {
func isDeploymentCommit(commit Commit) (ok bool, commitMessage CommitMessageDetails) {
// Examples: "Deployed mas-billing api-billing version v1.37.0 to prod"
// "Deployed mas-billing api-billing version v1.37.0-RC.2 to sta"
pattern := `Deployed\s(\w\S+)\s(\w\S+)\sversion\s(v\d+\.\d+\.\d+\S*)\sto\s(prod|sta|dev)`
// "Deployed mas-billing api-billing version v1.37.0 to STA"
pattern := `Deployed\s(\w\S+)\s(\w\S+)\sversion\s(v\d+\.\d+\.\d+\S*)\sto\s((?i)prod|sta|dev)`
re := regexp.MustCompile(pattern)

matches := re.FindStringSubmatch(commit.getCommitMessageTitle())
Expand Down
19 changes: 19 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,22 @@ func Test_isDeploymentCommit(t *testing.T) {
assert.True(t, ok)
assert.Equal(t, expectedCommitMessageDetails, actualCommitMessageDetails)
}

func Test_isDeploymentCommit_capitalLetters(t *testing.T) {
// Given
commit := Commit{
commitMessage: "Deployed mas-billing api-billing version v1.37.1 to STA\n\ndeployments:\n- serviceName: api-billing\n type: RAMPED\n versions:\n from:\n - name: v1.37.0\n percent: 100\n artifact: empty\n to:\n - name: v1.37.1\n percent: 100\n artifact: empty\n jira:\n issues: [MBIL-3468]\n changelog: |\n feat(mas-billing|commons): MBIL-3468 Implement a common contextual logger (#41988)",
}
expectedCommitMessageDetails := CommitMessageDetails{
domain: "mas-billing",
service: "api-billing",
version: "v1.37.1",
environment: "STA",
}
// When
ok, actualCommitMessageDetails := isDeploymentCommit(commit)

// Then
assert.True(t, ok)
assert.Equal(t, expectedCommitMessageDetails, actualCommitMessageDetails)
}

0 comments on commit 7c66ff0

Please sign in to comment.