diff options
author | Unknwon <u@gogs.io> | 2015-10-04 20:54:06 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-10-04 20:54:06 -0400 |
commit | 215920772ab8d84418e982ee1de8986f911fe3c1 (patch) | |
tree | b3cd6bce4ae72ca497cf9835ea2f7b6cd96bff4b /modules/git | |
parent | 02d3b662654d1627ad510b7b330c016e97a7d1af (diff) | |
download | gitea-215920772ab8d84418e982ee1de8986f911fe3c1.tar.gz gitea-215920772ab8d84418e982ee1de8986f911fe3c1.zip |
save PR info as patch and minor fix on PR
Diffstat (limited to 'modules/git')
-rw-r--r-- | modules/git/repo_pull.go | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/modules/git/repo_pull.go b/modules/git/repo_pull.go index add32df908..a9cc33a1d4 100644 --- a/modules/git/repo_pull.go +++ b/modules/git/repo_pull.go @@ -44,7 +44,7 @@ func (repo *Repository) GetPullRequestInfo(basePath, baseBranch, headBranch stri } prInfo.MergeBase = strings.TrimSpace(stdout) - stdout, stderr, err = com.ExecCmdDir(repo.Path, "git", "log", remoteBranch+"..."+headBranch, prettyLogFormat) + stdout, stderr, err = com.ExecCmdDir(repo.Path, "git", "log", prInfo.MergeBase+"..."+headBranch, prettyLogFormat) if err != nil { return nil, fmt.Errorf("list diff logs: %v", concatenateError(err, stderr)) } @@ -64,20 +64,8 @@ func (repo *Repository) GetPullRequestInfo(basePath, baseBranch, headBranch stri } // GetPatch generates and returns patch data between given branches. -func (repo *Repository) GetPatch(basePath, baseBranch, headBranch string) ([]byte, error) { - // Add a temporary remote. - tmpRemote := com.ToStr(time.Now().UnixNano()) - _, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "remote", "add", "-f", tmpRemote, basePath) - if err != nil { - return nil, fmt.Errorf("add base as remote: %v", concatenateError(err, string(stderr))) - } - defer func() { - com.ExecCmdDir(repo.Path, "git", "remote", "remove", tmpRemote) - }() - - var stdout []byte - remoteBranch := "remotes/" + tmpRemote + "/" + baseBranch - stdout, stderr, err = com.ExecCmdDirBytes(repo.Path, "git", "diff", "-p", remoteBranch, headBranch) +func (repo *Repository) GetPatch(mergeBase, headBranch string) ([]byte, error) { + stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "diff", "-p", mergeBase, headBranch) if err != nil { return nil, concatenateError(err, string(stderr)) } |