diff options
author | Norwin <noerw@users.noreply.github.com> | 2021-09-27 23:09:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-27 17:09:49 -0400 |
commit | f48dce3176649916c262ab080d5f38a0433f38c0 (patch) | |
tree | d009bc163d78577666dc462d376d697f600ef2d1 /services | |
parent | e8574f2f7d4648b5b3fda48f3e31599a6b9dd40b (diff) | |
download | gitea-f48dce3176649916c262ab080d5f38a0433f38c0.tar.gz gitea-f48dce3176649916c262ab080d5f38a0433f38c0.zip |
Don't return binary file changes in raw PR diffs by default (#17158)
* return diffs without binary file content change
* ?binary=true option to restore old behaviour
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'services')
-rw-r--r-- | services/pull/patch.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/services/pull/patch.go b/services/pull/patch.go index 184da9f659..27d7991919 100644 --- a/services/pull/patch.go +++ b/services/pull/patch.go @@ -22,7 +22,7 @@ import ( ) // DownloadDiffOrPatch will write the patch for the pr to the writer -func DownloadDiffOrPatch(pr *models.PullRequest, w io.Writer, patch bool) error { +func DownloadDiffOrPatch(pr *models.PullRequest, w io.Writer, patch, binary bool) error { if err := pr.LoadBaseRepo(); err != nil { log.Error("Unable to load base repository ID %d for pr #%d [%d]", pr.BaseRepoID, pr.Index, pr.ID) return err @@ -33,7 +33,7 @@ func DownloadDiffOrPatch(pr *models.PullRequest, w io.Writer, patch bool) error return fmt.Errorf("OpenRepository: %v", err) } defer gitRepo.Close() - if err := gitRepo.GetDiffOrPatch(pr.MergeBase, pr.GetGitRefName(), w, patch); err != nil { + if err := gitRepo.GetDiffOrPatch(pr.MergeBase, pr.GetGitRefName(), w, patch, binary); err != nil { log.Error("Unable to get patch file from %s to %s in %s Error: %v", pr.MergeBase, pr.HeadBranch, pr.BaseRepo.FullName(), err) return fmt.Errorf("Unable to get patch file from %s to %s in %s Error: %v", pr.MergeBase, pr.HeadBranch, pr.BaseRepo.FullName(), err) } @@ -108,7 +108,7 @@ func checkConflicts(pr *models.PullRequest, gitRepo *git.Repository, tmpBasePath _ = util.Remove(tmpPatchFile.Name()) }() - if err := gitRepo.GetDiff(pr.MergeBase, "tracking", tmpPatchFile); err != nil { + if err := gitRepo.GetDiffBinary(pr.MergeBase, "tracking", tmpPatchFile); err != nil { tmpPatchFile.Close() log.Error("Unable to get patch file from %s to %s in %s Error: %v", pr.MergeBase, pr.HeadBranch, pr.BaseRepo.FullName(), err) return false, fmt.Errorf("Unable to get patch file from %s to %s in %s Error: %v", pr.MergeBase, pr.HeadBranch, pr.BaseRepo.FullName(), err) |