-
Notifications
You must be signed in to change notification settings - Fork 38
Add GetFormatPatch receiver for a repository #103
Conversation
Includes test
I don't know why |
Could diff contain binary data? |
I guess so. Ok will add --binary switch and return binary. Will need to find out how to convert the |
Also add missing test file
pushed binary output, and the test file which was previously missing |
Also I think it would be better to use RunInDirPipeline and stream stdout io.Copy it later directly to response writer to not use so much memory for large diffs |
yes, I like that better too, now if I'd knew how to do it :) |
package git | ||
|
||
import ( | ||
"testing" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add an empty line here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done with 9783381
@@ -73,3 +73,8 @@ 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) ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the gitea PR I'd implement a GetFormatPatchReader(base, head string) (io.ReadCloser, error)
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm out of time for today so what about merging this and then improve later ? I'm looking forward for your PR implementing the "Reader" version of both methods (GetPatchReader and GEtFormatPatchReader)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging @strk PR would be much appreciated.
Includes test