Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions modules/git/gitcmd/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ func StderrHasPrefix(err error, prefix string) bool {
return strings.HasPrefix(stderr, prefix)
}

func StderrContains(err error, sub string) bool {
stderr, ok := ErrorAsStderr(err)
if !ok {
return false
}
return strings.Contains(stderr, sub)
}
Comment thread
wxiaoguang marked this conversation as resolved.

func IsErrorExitCode(err error, code int) bool {
var exitError *exec.ExitError
if errors.As(err, &exitError) {
Expand Down
6 changes: 3 additions & 3 deletions routers/api/v1/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ func parseCompareInfo(ctx *context.APIContext, compareParam string) (result *git
return nil, nil
}

return compareInfo, closer
return &compareInfo, closer
}

// UpdatePullRequest merge PR's baseBranch into headBranch
Expand Down Expand Up @@ -1419,14 +1419,14 @@ func GetPullRequestCommits(ctx *context.APIContext) {
return
}

var compareInfo *git_service.CompareInfo
baseGitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, pr.BaseRepo)
if err != nil {
ctx.APIErrorInternal(err)
return
}
defer closer.Close()

var compareInfo git_service.CompareInfo
if pr.HasMerged {
compareInfo, err = git_service.GetCompareInfo(ctx, pr.BaseRepo, pr.BaseRepo, baseGitRepo, git.RefName(pr.MergeBase), git.RefName(pr.GetGitHeadRefName()), false, false)
} else {
Expand Down Expand Up @@ -1552,7 +1552,7 @@ func GetPullRequestFiles(ctx *context.APIContext) {

baseGitRepo := ctx.Repo.GitRepo

var compareInfo *git_service.CompareInfo
var compareInfo git_service.CompareInfo
if pr.HasMerged {
compareInfo, err = git_service.GetCompareInfo(ctx, pr.BaseRepo, pr.BaseRepo, baseGitRepo, git.RefName(pr.MergeBase), git.RefName(pr.GetGitHeadRefName()), false, false)
} else {
Expand Down
3 changes: 1 addition & 2 deletions routers/web/repo/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,7 @@ func ParseCompareInfo(ctx *context.Context) *git_service.CompareInfo {
} else {
ctx.Data["BeforeCommitID"] = compareInfo.MergeBase
}

return compareInfo
return &compareInfo
}

func prepareNewPullRequestTitleContent(ci *git_service.CompareInfo, commits []*git_model.SignCommitWithStatuses) (title, content string) {
Expand Down
15 changes: 12 additions & 3 deletions routers/web/repo/issue_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,13 @@ func ViewIssue(ctx *context.Context) {
prepareIssueViewSidebarTimeTracker,
prepareIssueViewSidebarDependency,
prepareIssueViewSidebarPin,
func(ctx *context.Context, issue *issues_model.Issue) { preparePullViewPullInfo(ctx, issue) },
preparePullViewReviewAndMerge,
}

if issue.IsPull {
prepareFuncs = append(prepareFuncs,
func(ctx *context.Context, issue *issues_model.Issue) { preparePullViewPullInfo(ctx, issue) },
preparePullViewReviewAndMerge,
)
}
for _, prepareFunc := range prepareFuncs {
prepareFunc(ctx, issue)
if ctx.Written() {
Expand Down Expand Up @@ -443,7 +446,13 @@ func ViewPullMergeBox(ctx *context.Context) {
return
}
preparePullViewPullInfo(ctx, issue)
if ctx.Written() {
return
}
preparePullViewReviewAndMerge(ctx, issue)
if ctx.Written() {
return
}
ctx.Data["PullMergeBoxReloading"] = issue.PullRequest.IsChecking()

// TODO: it should use a dedicated struct to render the pull merge box, to make sure all data is prepared correctly
Expand Down
Loading