summaryrefslogtreecommitdiffstats
path: root/services/pull/temp_repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/pull/temp_repo.go')
-rw-r--r--services/pull/temp_repo.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/services/pull/temp_repo.go b/services/pull/temp_repo.go
index 19b488790a..54d09c8158 100644
--- a/services/pull/temp_repo.go
+++ b/services/pull/temp_repo.go
@@ -140,7 +140,15 @@ func createTemporaryRepo(pr *models.PullRequest) (string, error) {
trackingBranch := "tracking"
// Fetch head branch
- if err := git.NewCommand("fetch", "--no-tags", remoteRepoName, git.BranchPrefix+pr.HeadBranch+":"+trackingBranch).RunInDirPipeline(tmpBasePath, &outbuf, &errbuf); err != nil {
+ var headBranch string
+ if pr.Flow == models.PullRequestFlowGithub {
+ headBranch = git.BranchPrefix + pr.HeadBranch
+ } else if len(pr.HeadCommitID) == 40 { // for not created pull request
+ headBranch = pr.HeadCommitID
+ } else {
+ headBranch = pr.GetGitRefName()
+ }
+ if err := git.NewCommand("fetch", "--no-tags", remoteRepoName, headBranch+":"+trackingBranch).RunInDirPipeline(tmpBasePath, &outbuf, &errbuf); err != nil {
if err := models.RemoveTemporaryPath(tmpBasePath); err != nil {
log.Error("CreateTempRepo: RemoveTemporaryPath: %s", err)
}
@@ -150,7 +158,7 @@ func createTemporaryRepo(pr *models.PullRequest) (string, error) {
}
}
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())
- return "", fmt.Errorf("Unable to fetch head_repo head branch [%s:%s -> tracking in tmpBasePath]: %v\n%s\n%s", pr.HeadRepo.FullName(), pr.HeadBranch, err, outbuf.String(), errbuf.String())
+ return "", fmt.Errorf("Unable to fetch head_repo head branch [%s:%s -> tracking in tmpBasePath]: %v\n%s\n%s", pr.HeadRepo.FullName(), headBranch, err, outbuf.String(), errbuf.String())
}
outbuf.Reset()
errbuf.Reset()