Skip to content

Commit

Permalink
fix gcp with perfix (#548)
Browse files Browse the repository at this point in the history
Co-authored-by: ChanochShayner <[email protected]>
  • Loading branch information
MiriamKaufman and ChanochShayner authored Jul 25, 2024
1 parent b7795e4 commit e758544
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/common/tagging/gittag/git_tag_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@ func (t *TagGroup) hasNonTagChanges(blame *gitservice.GitBlame, block structure.

func (t *TagGroup) cleanGCPTagValue(val tags.ITag) {
updated := val.GetValue()
switch val.GetKey() {
keyValue := val.GetKey()
if t.Options.TagPrefix != "" {
keyValue = strings.TrimPrefix(keyValue, t.Options.TagPrefix)
}
switch keyValue {
case tags.GitModifiersTagKey:
modifiers := strings.Split(updated, "/")
for i, m := range modifiers {
Expand Down
8 changes: 8 additions & 0 deletions src/common/tagging/gittag/git_tag_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ func TestGitTagGroupWithPrefix(t *testing.T) {
assert.True(t, strings.HasPrefix(tag.GetKey(), "prefix_"))
}
}
func TestCleanGCPTagValueWithTagPrefix(t *testing.T) {
tagGroup := TagGroup{}
tagGroup.Options.TagPrefix = "prefix_"
tag := &tags.Tag{Key: "prefix_" + tags.GitFileTagKey, Value: "test/to/path"}
tagGroup.cleanGCPTagValue(tag)
assert.Equal(t, "test__to__path", tag.GetValue())

}

var ExpectedFileMappingTagged = map[string]map[int]int{
"originToGit": {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: -1, 7: -1, 8: -1, 9: -1, 10: -1, 11: -1, 12: -1, 13: -1, 14: -1, 15: -1, 16: 6, 17: 7, 18: 8, 19: 9, 20: 10, 21: 11, 22: 12},
Expand Down

0 comments on commit e758544

Please sign in to comment.