Skip to content
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

Use tags only in case of perfect match #755

Merged
merged 1 commit into from
Jun 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions pkg/skaffold/build/tag/git_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ func generateNameGitShellOut(workingDir string, opts *Options) (string, error) {
return dirtyTag(currentTag, opts), nil
}

tags, err := runGitLines(root, "describe", "--tags", "--always")
if err != nil {
return "", errors.Wrap(err, "getting tags")
}
// Ignore error. It means there's no tag.
tags, _ := runGitLines(root, "describe", "--tags", "--exact-match")

return commitOrTag(currentTag, tags, opts), nil
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/skaffold/build/tag/git_commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ func TestGitCommit_GenerateFullyQualifiedImageName(t *testing.T) {
write("new.go", []byte("new code"))
},
},
{
description: "don't use tag if not exact match",
expectedName: "test:3cec6b9",
createGitRepo: func(dir string) {
gitInit(t, dir).
write("source.go", []byte("code")).
add("source.go").
commit("initial").
tag("v1").
write("source.go", []byte("updated code")).
add("source.go").
commit("changes")
},
},
{
description: "deleted file",
expectedName: "test:279d53f-dirty-abababa",
Expand Down