From 44053532bb7c5b7fcd65fd5246780db8cf446f7e Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Sun, 7 Jan 2018 14:10:20 +0100 Subject: Serve .patch for pull requests (#3305) * Serve .patch for pull requests Closes #3259 Updates "git" module, for GetFormatPatch * Handle io.Copy error --- vendor/code.gitea.io/git/repo_pull.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'vendor/code.gitea.io/git/repo_pull.go') diff --git a/vendor/code.gitea.io/git/repo_pull.go b/vendor/code.gitea.io/git/repo_pull.go index 1c45a4e027..c6d97a6fd1 100644 --- a/vendor/code.gitea.io/git/repo_pull.go +++ b/vendor/code.gitea.io/git/repo_pull.go @@ -5,8 +5,10 @@ package git import ( + "bytes" "container/list" "fmt" + "io" "strconv" "strings" "time" @@ -73,3 +75,15 @@ func (repo *Repository) GetPullRequestInfo(basePath, baseBranch, headBranch stri func (repo *Repository) GetPatch(base, head string) ([]byte, error) { return NewCommand("diff", "-p", "--binary", base, head).RunInDirBytes(repo.Path) } + +// GetFormatPatch generates and returns format-patch data between given revisions. +func (repo *Repository) GetFormatPatch(base, head string) (io.Reader, error) { + stdout := new(bytes.Buffer) + stderr := new(bytes.Buffer) + + if err := NewCommand("format-patch", "--binary", "--stdout", base+"..."+head). + RunInDirPipeline(repo.Path, stdout, stderr); err != nil { + return nil, concatenateError(err, stderr.String()) + } + return stdout, nil +} -- cgit v1.2.3