diff options
author | Lauris BH <lauris@nix.lv> | 2018-01-19 08:18:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-19 08:18:51 +0200 |
commit | ca306985d35f295fb2a2f8a54661731462426281 (patch) | |
tree | c63ec4474aecd21a39fd0b7aeac34df602f92311 /models | |
parent | b0d5bb909b2e558bee5d4d58f201012d5f8b4c1c (diff) | |
download | gitea-ca306985d35f295fb2a2f8a54661731462426281.tar.gz gitea-ca306985d35f295fb2a2f8a54661731462426281.zip |
Change how merged PR commit info are prepared (#3368)
* Change how merged PR commits and diff are made
* Update code.gitea.io/git dependency
* Fix typo
* Remove unneeded local variable
Diffstat (limited to 'models')
-rw-r--r-- | models/pull.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/models/pull.go b/models/pull.go index 38312e4e40..5c54a2268a 100644 --- a/models/pull.go +++ b/models/pull.go @@ -132,6 +132,11 @@ func (pr *PullRequest) GetDefaultSquashMessage() string { return fmt.Sprintf("%s (#%d)", pr.Issue.Title, pr.Issue.Index) } +// GetGitRefName returns git ref for hidden pull request branch +func (pr *PullRequest) GetGitRefName() string { + return fmt.Sprintf("refs/pull/%d/head", pr.Index) +} + // APIFormat assumes following fields have been assigned with valid values: // Required - Issue // Optional - Merger @@ -562,7 +567,7 @@ func (pr *PullRequest) getMergeCommit() (*git.Commit, error) { indexTmpPath := filepath.Join(os.TempDir(), "gitea-"+pr.BaseRepo.Name+"-"+strconv.Itoa(time.Now().Nanosecond())) defer os.Remove(indexTmpPath) - headFile := fmt.Sprintf("refs/pull/%d/head", pr.Index) + headFile := pr.GetGitRefName() // Check if a pull request is merged into BaseBranch _, stderr, err := process.GetManager().ExecDirEnv(-1, "", fmt.Sprintf("isMerged (git merge-base --is-ancestor): %d", pr.BaseRepo.ID), @@ -980,7 +985,7 @@ func (pr *PullRequest) UpdatePatch() (err error) { // corresponding branches of base repository. // FIXME: Only push branches that are actually updates? func (pr *PullRequest) PushToBaseRepo() (err error) { - log.Trace("PushToBaseRepo[%d]: pushing commits to base repo 'refs/pull/%d/head'", pr.BaseRepoID, pr.Index) + log.Trace("PushToBaseRepo[%d]: pushing commits to base repo '%s'", pr.BaseRepoID, pr.GetGitRefName()) headRepoPath := pr.HeadRepo.RepoPath() headGitRepo, err := git.OpenRepository(headRepoPath) @@ -995,7 +1000,7 @@ func (pr *PullRequest) PushToBaseRepo() (err error) { // Make sure to remove the remote even if the push fails defer headGitRepo.RemoveRemote(tmpRemoteName) - headFile := fmt.Sprintf("refs/pull/%d/head", pr.Index) + headFile := pr.GetGitRefName() // Remove head in case there is a conflict. file := path.Join(pr.BaseRepo.RepoPath(), headFile) |