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

Backport: Strict name matching for Repository.GetTagID() #8082

Merged
merged 3 commits into from Sep 4, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

Strict name matching for Repository.GetTagID()

  • Loading branch information...
guillep2k committed Sep 4, 2019
commit b60b48a77dec537d39c23062303dc1dff79f36d6
@@ -157,11 +157,14 @@ func (repo *Repository) GetTagID(name string) (string, error) {
if err != nil {
return "", err
}
fields := strings.Fields(stdout)
if len(fields) != 2 {
return "", ErrNotExist{ID: name}
// Make sure exact match is used: "v1" != "release/v1"
for _, line := range strings.Split(stdout, "\n") {
fields := strings.Fields(line)
if len(fields) == 2 && fields[1] == "refs/tags/"+name {
return fields[0], nil
}
}
return fields[0], nil
return "", ErrNotExist{ID: name}
}

// GetTag returns a Git tag by given name.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.