mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-23 21:04:55 +02:00
refactor(git): replace git stderr matching with exit codes (#39866)
Matching git's stderr text is fragile because it breaks silently when git rewords a message. Where git offers an exit code or a query with a defined answer, use that instead, and drop matches that could never trigger. Follow-up to the discussion in https://github.com/go-gitea/gitea/pull/39857. - Detect a missing remote by `git remote` exit code 2 - Resolve annotated tags to their tree with cat-file `^{tree}` instead of spawning `ls-tree` when listing tree entries - Skip the wiki page lookup when the default branch doesn't exist yet - Remove unreachable "no merge base" and "unknown revision" checks
This commit is contained in:
1 parent
52eb515751
commit
738ff1d65a
12 files changed
+57
-92
No files matched your search
@@ -370,8 +370,7 @@ func (prInfo *pullRequestViewInfo) prepareViewFillCompareInfo(ctx *context.Conte
|
||||
pull := prInfo.issue.PullRequest
|
||||
prInfo.CompareInfo, err = git_service.GetCompareInfo(ctx, ctx.Repo.Repository, ctx.Repo.Repository, ctx.Repo.GitRepo, baseRef, git.RefName(pull.GetGitHeadRefName()), false, false)
|
||||
if err != nil {
|
||||
isKnownErrorForBroken := errors.Is(err, util.ErrNotExist) || gitcmd.IsStderr(err, gitcmd.StderrNotValidObjectName) || gitcmd.IsStderr(err, gitcmd.StderrUnknownRevisionOrPath)
|
||||
if !isKnownErrorForBroken {
|
||||
if !errors.Is(err, util.ErrNotExist) && !gitcmd.IsStderr(err, gitcmd.StderrNotValidObjectName) {
|
||||
log.Error("GetCompareInfo: %v", err)
|
||||
}
|
||||
prInfo.IsPullRequestBroken = true
|
||||
|
||||
Reference in new issue
Block a user