mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-01 09:28:30 +02:00
Fix bug (#793)
Partially fix #791 Reviewed-on: https://gitea.com/gitea/tea/pulls/793 Reviewed-by: hiifong <i@hiif.ong>
This commit is contained in:
@ -6,6 +6,7 @@ package pulls
|
||||
import (
|
||||
stdctx "context"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/interact"
|
||||
@ -56,11 +57,16 @@ func runPullsCreate(_ stdctx.Context, cmd *cli.Command) error {
|
||||
return err
|
||||
}
|
||||
|
||||
var allowMaintainerEdits *bool
|
||||
if ctx.IsSet("allow-maintainer-edits") {
|
||||
allowMaintainerEdits = gitea.OptionalBool(ctx.Bool("allow-maintainer-edits"))
|
||||
}
|
||||
|
||||
return task.CreatePull(
|
||||
ctx,
|
||||
ctx.String("base"),
|
||||
ctx.String("head"),
|
||||
ctx.Bool("allow-maintainer-edits"),
|
||||
allowMaintainerEdits,
|
||||
opts,
|
||||
)
|
||||
}
|
||||
|
@ -72,6 +72,6 @@ func CreatePull(ctx *context.TeaContext) (err error) {
|
||||
ctx,
|
||||
base,
|
||||
head,
|
||||
allowMaintainerEdits,
|
||||
&allowMaintainerEdits,
|
||||
&opts)
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ var (
|
||||
)
|
||||
|
||||
// CreatePull creates a PR in the given repo and prints the result
|
||||
func CreatePull(ctx *context.TeaContext, base, head string, allowMaintainerEdits bool, opts *gitea.CreateIssueOption) (err error) {
|
||||
func CreatePull(ctx *context.TeaContext, base, head string, allowMaintainerEdits *bool, opts *gitea.CreateIssueOption) (err error) {
|
||||
// default is default branch
|
||||
if len(base) == 0 {
|
||||
base, err = GetDefaultPRBase(ctx.Login, ctx.Owner, ctx.Repo)
|
||||
@ -75,9 +75,9 @@ func CreatePull(ctx *context.TeaContext, base, head string, allowMaintainerEdits
|
||||
return fmt.Errorf("could not create PR from %s to %s:%s: %s", head, ctx.Owner, base, err)
|
||||
}
|
||||
|
||||
if pr.AllowMaintainerEdit != allowMaintainerEdits {
|
||||
if allowMaintainerEdits != nil && pr.AllowMaintainerEdit != *allowMaintainerEdits {
|
||||
pr, _, err = client.EditPullRequest(ctx.Owner, ctx.Repo, pr.Index, gitea.EditPullRequestOption{
|
||||
AllowMaintainerEdit: gitea.OptionalBool(allowMaintainerEdits),
|
||||
AllowMaintainerEdit: allowMaintainerEdits,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not enable maintainer edit on pull: %v", err)
|
||||
|
Reference in New Issue
Block a user