pulls

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdPullsApprove = cli.Command{
	Name:        "approve",
	Aliases:     []string{"lgtm", "a"},
	Usage:       "Approve a pull request",
	Description: "Approve a pull request",
	ArgsUsage:   "<pull index> [<comment>]",
	Action: func(cmd *cli.Context) error {
		ctx := context.InitCommand(cmd)
		ctx.Ensure(context.CtxRequirement{RemoteRepo: true})

		if ctx.Args().Len() == 0 {
			return fmt.Errorf("Must specify a PR index")
		}

		idx, err := utils.ArgToIndex(ctx.Args().First())
		if err != nil {
			return err
		}

		comment := strings.Join(ctx.Args().Tail(), " ")

		return task.CreatePullReview(ctx, idx, gitea.ReviewStateApproved, comment, nil)
	},
	Flags: flags.AllDefaultFlags,
}

CmdPullsApprove approves a PR

View Source
var CmdPullsCheckout = cli.Command{
	Name:        "checkout",
	Aliases:     []string{"co"},
	Usage:       "Locally check out the given PR",
	Description: `Locally check out the given PR`,
	Action:      runPullsCheckout,
	ArgsUsage:   "<pull index>",
	Flags: append([]cli.Flag{
		&cli.BoolFlag{
			Name:    "branch",
			Aliases: []string{"b"},
			Usage:   "Create a local branch if it doesn't exist yet",
		},
	}, flags.AllDefaultFlags...),
}

CmdPullsCheckout is a command to locally checkout the given PR

View Source
var CmdPullsClean = cli.Command{
	Name:        "clean",
	Usage:       "Deletes local & remote feature-branches for a closed pull request",
	Description: `Deletes local & remote feature-branches for a closed pull request`,
	ArgsUsage:   "<pull index>",
	Action:      runPullsClean,
	Flags: append([]cli.Flag{
		&cli.BoolFlag{
			Name:  "ignore-sha",
			Usage: "Find the local branch by name instead of commit hash (less precise)",
		},
	}, flags.AllDefaultFlags...),
}

CmdPullsClean removes the remote and local feature branches, if a PR is merged.

View Source
var CmdPullsClose = cli.Command{
	Name:        "close",
	Usage:       "Change state of a pull request to 'closed'",
	Description: `Change state of a pull request to 'closed'`,
	ArgsUsage:   "<pull index>",
	Action: func(ctx *cli.Context) error {
		var s = gitea.StateClosed
		return editPullState(ctx, gitea.EditPullRequestOption{State: &s})
	},
	Flags: flags.AllDefaultFlags,
}

CmdPullsClose closes a given open pull request

View Source
var CmdPullsCreate = cli.Command{
	Name:        "create",
	Aliases:     []string{"c"},
	Usage:       "Create a pull-request",
	Description: "Create a pull-request in the current repo",
	Action:      runPullsCreate,
	Flags: append([]cli.Flag{
		&cli.StringFlag{
			Name:  "head",
			Usage: "Branch name of the PR source (default is current one). To specify a different head repo, use <user>:<branch>",
		},
		&cli.StringFlag{
			Name:    "base",
			Aliases: []string{"b"},
			Usage:   "Branch name of the PR target (default is repos default branch)",
		},
	}, flags.IssuePREditFlags...),
}

CmdPullsCreate creates a pull request

View Source
var CmdPullsList = cli.Command{
	Name:        "list",
	Aliases:     []string{"ls"},
	Usage:       "List pull requests of the repository",
	Description: `List pull requests of the repository`,
	ArgsUsage:   " ",
	Action:      RunPullsList,
	Flags:       append([]cli.Flag{pullFieldsFlag}, flags.PRListingFlags...),
}

CmdPullsList represents a sub command of issues to list pulls

View Source
var CmdPullsMerge = cli.Command{
	Name:        "merge",
	Aliases:     []string{"m"},
	Usage:       "Merge a pull request",
	Description: "Merge a pull request",
	ArgsUsage:   "<pull index>",
	Flags: append([]cli.Flag{
		&cli.StringFlag{
			Name:    "style",
			Aliases: []string{"s"},
			Usage:   "Kind of merge to perform: merge, rebase, squash, rebase-merge",
			Value:   "merge",
		},
		&cli.StringFlag{
			Name:    "title",
			Aliases: []string{"t"},
			Usage:   "Merge commit title",
		},
		&cli.StringFlag{
			Name:    "message",
			Aliases: []string{"m"},
			Usage:   "Merge commit message",
		},
	}, flags.AllDefaultFlags...),
	Action: func(cmd *cli.Context) error {
		ctx := context.InitCommand(cmd)
		ctx.Ensure(context.CtxRequirement{RemoteRepo: true})

		if ctx.Args().Len() != 1 {
			return fmt.Errorf("Must specify a PR index")
		}

		idx, err := utils.ArgToIndex(ctx.Args().First())
		if err != nil {
			return err
		}

		success, _, err := ctx.Login.Client().MergePullRequest(ctx.Owner, ctx.Repo, idx, gitea.MergePullRequestOption{
			Style:   gitea.MergeStyle(ctx.String("style")),
			Title:   ctx.String("title"),
			Message: ctx.String("message"),
		})

		if err != nil {
			return err
		}
		if !success {
			return fmt.Errorf("Failed to merge PR. Is it still open?")
		}
		return nil
	},
}

CmdPullsMerge merges a PR

View Source
var CmdPullsReject = cli.Command{
	Name:        "reject",
	Usage:       "Request changes to a pull request",
	Description: "Request changes to a pull request",
	ArgsUsage:   "<pull index> <reason>",
	Action: func(cmd *cli.Context) error {
		ctx := context.InitCommand(cmd)
		ctx.Ensure(context.CtxRequirement{RemoteRepo: true})

		if ctx.Args().Len() < 2 {
			return fmt.Errorf("Must specify a PR index and comment")
		}

		idx, err := utils.ArgToIndex(ctx.Args().First())
		if err != nil {
			return err
		}

		comment := strings.Join(ctx.Args().Tail(), " ")

		return task.CreatePullReview(ctx, idx, gitea.ReviewStateRequestChanges, comment, nil)
	},
	Flags: flags.AllDefaultFlags,
}

CmdPullsReject requests changes to a PR

View Source
var CmdPullsReopen = cli.Command{
	Name:        "reopen",
	Aliases:     []string{"open"},
	Usage:       "Change state of a pull request to 'open'",
	Description: `Change state of a pull request to 'open'`,
	ArgsUsage:   "<pull index>",
	Action: func(ctx *cli.Context) error {
		var s = gitea.StateOpen
		return editPullState(ctx, gitea.EditPullRequestOption{State: &s})
	},
	Flags: flags.AllDefaultFlags,
}

CmdPullsReopen reopens a given closed pull request

View Source
var CmdPullsReview = cli.Command{
	Name:        "review",
	Usage:       "Interactively review a pull request",
	Description: "Interactively review a pull request",
	ArgsUsage:   "<pull index>",
	Action: func(cmd *cli.Context) error {
		ctx := context.InitCommand(cmd)
		ctx.Ensure(context.CtxRequirement{RemoteRepo: true})

		if ctx.Args().Len() != 1 {
			return fmt.Errorf("Must specify a PR index")
		}

		idx, err := utils.ArgToIndex(ctx.Args().First())
		if err != nil {
			return err
		}

		return interact.ReviewPull(ctx, idx)
	},
	Flags: flags.AllDefaultFlags,
}

CmdPullsReview starts an interactive review session

Functions

func RunPullsList

func RunPullsList(cmd *cli.Context) error

RunPullsList return list of pulls

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL