summaryrefslogtreecommitdiffstats
path: root/models/pull.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-11-20 02:53:54 -0500
committerUnknwon <u@gogs.io>2015-11-20 02:53:54 -0500
commit1d4a5b1825e46b51a1cbd6dc5d24a4ea585a0e72 (patch)
tree4b553e42abab98df2ea228e9d67b9d91c531f570 /models/pull.go
parent987dcc5372998adaafb68e00a9a460e955d018e5 (diff)
downloadgitea-1d4a5b1825e46b51a1cbd6dc5d24a4ea585a0e72.tar.gz
gitea-1d4a5b1825e46b51a1cbd6dc5d24a4ea585a0e72.zip
fix #2002
Diffstat (limited to 'models/pull.go')
-rw-r--r--models/pull.go30
1 files changed, 18 insertions, 12 deletions
diff --git a/models/pull.go b/models/pull.go
index 5c7d4a3f90..e67d242e90 100644
--- a/models/pull.go
+++ b/models/pull.go
@@ -166,43 +166,49 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error
var stderr string
if _, stderr, err = process.ExecTimeout(5*time.Minute,
- fmt.Sprintf("PullRequest.Merge(git clone): %s", tmpBasePath),
+ fmt.Sprintf("PullRequest.Merge (git clone): %s", tmpBasePath),
"git", "clone", baseGitRepo.Path, tmpBasePath); err != nil {
return fmt.Errorf("git clone: %s", stderr)
}
// Check out base branch.
if _, stderr, err = process.ExecDir(-1, tmpBasePath,
- fmt.Sprintf("PullRequest.Merge(git checkout): %s", tmpBasePath),
+ fmt.Sprintf("PullRequest.Merge (git checkout): %s", tmpBasePath),
"git", "checkout", pr.BaseBranch); err != nil {
return fmt.Errorf("git checkout: %s", stderr)
}
// Add head repo remote.
if _, stderr, err = process.ExecDir(-1, tmpBasePath,
- fmt.Sprintf("PullRequest.Merge(git remote add): %s", tmpBasePath),
+ fmt.Sprintf("PullRequest.Merge (git remote add): %s", tmpBasePath),
"git", "remote", "add", "head_repo", headRepoPath); err != nil {
- return fmt.Errorf("git remote add[%s -> %s]: %s", headRepoPath, tmpBasePath, stderr)
+ return fmt.Errorf("git remote add [%s -> %s]: %s", headRepoPath, tmpBasePath, stderr)
}
// Merge commits.
if _, stderr, err = process.ExecDir(-1, tmpBasePath,
- fmt.Sprintf("PullRequest.Merge(git fetch): %s", tmpBasePath),
+ fmt.Sprintf("PullRequest.Merge (git fetch): %s", tmpBasePath),
"git", "fetch", "head_repo"); err != nil {
- return fmt.Errorf("git fetch[%s -> %s]: %s", headRepoPath, tmpBasePath, stderr)
+ return fmt.Errorf("git fetch [%s -> %s]: %s", headRepoPath, tmpBasePath, stderr)
}
if _, stderr, err = process.ExecDir(-1, tmpBasePath,
- fmt.Sprintf("PullRequest.Merge(git merge): %s", tmpBasePath),
- "git", "merge", "--no-ff", "-m",
- fmt.Sprintf("Merge branch '%s' of %s/%s into %s", pr.HeadBranch, pr.HeadUserName, pr.HeadRepo.Name, pr.BaseBranch),
- "head_repo/"+pr.HeadBranch); err != nil {
- return fmt.Errorf("git merge[%s]: %s", tmpBasePath, stderr)
+ fmt.Sprintf("PullRequest.Merge (git merge --no-commit): %s", tmpBasePath),
+ "git", "merge", "--no-commit", "head_repo/"+pr.HeadBranch); err != nil {
+ return fmt.Errorf("git merge --no-commit [%s]: %s", tmpBasePath, stderr)
+ }
+
+ sig := doer.NewGitSig()
+ if _, stderr, err = process.ExecDir(-1, tmpBasePath,
+ fmt.Sprintf("PullRequest.Merge (git merge): %s", tmpBasePath),
+ "git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email),
+ "-m", fmt.Sprintf("Merge branch '%s' of %s/%s into %s", pr.HeadBranch, pr.HeadUserName, pr.HeadRepo.Name, pr.BaseBranch)); err != nil {
+ return fmt.Errorf("git commit [%s]: %s", tmpBasePath, stderr)
}
// Push back to upstream.
if _, stderr, err = process.ExecDir(-1, tmpBasePath,
- fmt.Sprintf("PullRequest.Merge(git push): %s", tmpBasePath),
+ fmt.Sprintf("PullRequest.Merge (git push): %s", tmpBasePath),
"git", "push", baseGitRepo.Path, pr.BaseBranch); err != nil {
return fmt.Errorf("git push: %s", stderr)
}