aboutsummaryrefslogtreecommitdiffstats
path: root/services/pull/temp_repo.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-06-12 00:49:47 +0100
committerGitHub <noreply@github.com>2020-06-11 19:49:47 -0400
commit0973c036019c955172ebce99d58eede2e9ac55ca (patch)
tree7c49364bba0ebfb4eb8c4bb5194f643629b929bc /services/pull/temp_repo.go
parent6c2a59b50c2af367281492b6c6adc9061e57b0a9 (diff)
downloadgitea-0973c036019c955172ebce99d58eede2e9ac55ca.tar.gz
gitea-0973c036019c955172ebce99d58eede2e9ac55ca.zip
Handle more pathological branch and tag names (#11843)
* Handle more pathological branch and tag names Signed-off-by: Andrew Thornton <art27@cantab.net> * Fix failing test Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'services/pull/temp_repo.go')
-rw-r--r--services/pull/temp_repo.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/services/pull/temp_repo.go b/services/pull/temp_repo.go
index 91f48d0626..45cd10b65b 100644
--- a/services/pull/temp_repo.go
+++ b/services/pull/temp_repo.go
@@ -100,7 +100,7 @@ func createTemporaryRepo(pr *models.PullRequest) (string, error) {
outbuf.Reset()
errbuf.Reset()
- if err := git.NewCommand("fetch", "origin", "--no-tags", pr.BaseBranch+":"+baseBranch, pr.BaseBranch+":original_"+baseBranch).RunInDirPipeline(tmpBasePath, &outbuf, &errbuf); err != nil {
+ if err := git.NewCommand("fetch", "origin", "--no-tags", "--", pr.BaseBranch+":"+baseBranch, pr.BaseBranch+":original_"+baseBranch).RunInDirPipeline(tmpBasePath, &outbuf, &errbuf); err != nil {
log.Error("Unable to fetch origin base branch [%s:%s -> base, original_base in %s]: %v:\n%s\n%s", pr.BaseRepo.FullName(), pr.BaseBranch, tmpBasePath, err, outbuf.String(), errbuf.String())
if err := models.RemoveTemporaryPath(tmpBasePath); err != nil {
log.Error("CreateTempRepo: RemoveTemporaryPath: %s", err)
@@ -140,7 +140,7 @@ func createTemporaryRepo(pr *models.PullRequest) (string, error) {
trackingBranch := "tracking"
// Fetch head branch
- if err := git.NewCommand("fetch", "--no-tags", remoteRepoName, pr.HeadBranch+":"+trackingBranch).RunInDirPipeline(tmpBasePath, &outbuf, &errbuf); err != nil {
+ if err := git.NewCommand("fetch", "--no-tags", remoteRepoName, git.BranchPrefix+pr.HeadBranch+":"+trackingBranch).RunInDirPipeline(tmpBasePath, &outbuf, &errbuf); err != nil {
log.Error("Unable to fetch head_repo head branch [%s:%s -> tracking in %s]: %v:\n%s\n%s", pr.HeadRepo.FullName(), pr.HeadBranch, tmpBasePath, err, outbuf.String(), errbuf.String())
if err := models.RemoveTemporaryPath(tmpBasePath); err != nil {
log.Error("CreateTempRepo: RemoveTemporaryPath: %s", err)