fix conflict

This commit is contained in:
Lunny Xiao 2024-12-10 13:31:47 -08:00
parent 8eb19a5ae1
commit 48b5bab880
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 12 additions and 12 deletions

View File

@ -233,17 +233,6 @@ func parseDiffStat(stdout string) (numFiles, totalAdditions, totalDeletions int,
return numFiles, totalAdditions, totalDeletions, err
}
// GetDiffOrPatch generates either diff or formatted patch data between given revisions
func (repo *Repository) GetDiffOrPatch(compareString string, w io.Writer, patch, binary bool) error {
if patch {
return repo.GetPatch(compareString, w)
}
if binary {
return repo.GetDiffBinary(compareString, w)
}
return repo.GetDiff(compareString, w)
}
func parseCompareArgs(compareArgs string) (args []string) {
parts := strings.Split(compareArgs, "...")
if len(parts) == 2 {

View File

@ -29,6 +29,17 @@ import (
"github.com/gobwas/glob"
)
// getDiffOrPatch generates either diff or formatted patch data between given revisions
func getDiffOrPatch(repo *git.Repository, compareString string, w io.Writer, patch, binary bool) error {
if patch {
return repo.GetPatch(compareString, w)
}
if binary {
return repo.GetDiffBinary(compareString, w)
}
return repo.GetDiff(compareString, w)
}
// DownloadDiffOrPatch will write the patch for the pr to the writer
func DownloadDiffOrPatch(ctx context.Context, pr *issues_model.PullRequest, w io.Writer, patch, binary bool) error {
if err := pr.LoadBaseRepo(ctx); err != nil {
@ -42,7 +53,7 @@ func DownloadDiffOrPatch(ctx context.Context, pr *issues_model.PullRequest, w io
}
defer closer.Close()
if err := gitRepo.GetDiffOrPatch(pr.MergeBase+".."+pr.GetGitRefName(), w, patch, binary); err != nil {
if err := getDiffOrPatch(gitRepo, 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: %w", pr.MergeBase, pr.HeadBranch, pr.BaseRepo.FullName(), err)
}