Serve .patch for pull requests (#3305)

* Serve .patch for pull requests

Closes #3259
Updates "git" module, for GetFormatPatch

* Handle io.Copy error
This commit is contained in:
Sandro Santilli 2018-01-07 14:10:20 +01:00 committed by Lauris BH
parent 18bb0f8f13
commit 44053532bb
7 changed files with 79 additions and 6 deletions

View file

@ -56,7 +56,15 @@ func TestPullCreate(t *testing.T) {
// check .diff can be accessed and matches performed change
req := NewRequest(t, "GET", url+".diff")
resp = session.MakeRequest(t, req, http.StatusOK)
assert.Regexp(t, "\\+Hello, World \\(Edited\\)", resp.Body)
assert.Regexp(t, `\+Hello, World \(Edited\)`, resp.Body)
assert.Regexp(t, "^diff", resp.Body)
assert.NotRegexp(t, "diff.*diff", resp.Body) // not two diffs, just one
// check .patch can be accessed and matches performed change
req = NewRequest(t, "GET", url+".patch")
resp = session.MakeRequest(t, req, http.StatusOK)
assert.Regexp(t, `\+Hello, World \(Edited\)`, resp.Body)
assert.Regexp(t, "diff", resp.Body)
assert.Regexp(t, `Subject: \[PATCH\] Update 'README.md'`, resp.Body)
assert.NotRegexp(t, "diff.*diff", resp.Body) // not two diffs, just one
}