From d78bf3fc3c6dfb2916e6337d848ac2bbf4b1c87e Mon Sep 17 00:00:00 2001 From: zeripath Date: Tue, 23 Aug 2022 19:12:43 +0100 Subject: [PATCH] Set no-tags in git fetch on compare (#20893) Backport #20893 In the compare endpoint the git fetch is restricted to a certain branch however, this does not completely prevent tag acquisition/pollution as git fetch will collect any tags on that branch. This causes pollution of the tag namespace and could cause confusion by users. This PR adds `--no-tags` to the `git fetch` call. Signed-off-by: Andrew Thornton --- modules/git/repo_compare.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/git/repo_compare.go b/modules/git/repo_compare.go index 3c7af73000e45..8a5972a02ff81 100644 --- a/modules/git/repo_compare.go +++ b/modules/git/repo_compare.go @@ -40,7 +40,7 @@ func (repo *Repository) GetMergeBase(tmpRemote, base, head string) (string, stri if tmpRemote != "origin" { tmpBaseName := RemotePrefix + tmpRemote + "/tmp_" + base // Fetch commit into a temporary branch in order to be able to handle commits and tags - _, _, err := NewCommand(repo.Ctx, "fetch", tmpRemote, base+":"+tmpBaseName).RunStdString(&RunOpts{Dir: repo.Path}) + _, _, err := NewCommand(repo.Ctx, "fetch", "--no-tags", tmpRemote, "--", base+":"+tmpBaseName).RunStdString(&RunOpts{Dir: repo.Path}) if err == nil { base = tmpBaseName }