mirror of
				https://gitea.com/gitea/tea.git
				synced 2025-10-31 01:05:26 +01:00 
			
		
		
		
	When there is no login detected, list all possible logins to select
This commit is contained in:
		| @@ -7,7 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/admin/users" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
| @@ -44,7 +44,7 @@ var cmdAdminUsers = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runAdminUserDetail(_ stdctx.Context, cmd *cli.Command, u string) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	client := ctx.Login.Client() | ||||
| 	user, _, err := client.GetUserInfo(u) | ||||
| 	if err != nil { | ||||
|   | ||||
| @@ -6,8 +6,8 @@ package users | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| @@ -34,7 +34,7 @@ var CmdUserList = cli.Command{ | ||||
|  | ||||
| // RunUserList list users | ||||
| func RunUserList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
|  | ||||
| 	fields, err := userFieldsFlag.GetValues(cmd) | ||||
| 	if err != nil { | ||||
|   | ||||
| @@ -9,6 +9,7 @@ import ( | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
|  | ||||
| @@ -27,7 +28,7 @@ var CmdReleaseAttachmentCreate = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runReleaseAttachmentCreate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
|  | ||||
| @@ -32,7 +33,7 @@ var CmdReleaseAttachmentDelete = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runReleaseAttachmentDelete(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| @@ -31,7 +32,7 @@ var CmdReleaseAttachmentList = cli.Command{ | ||||
|  | ||||
| // RunReleaseAttachmentList list release attachments | ||||
| func RunReleaseAttachmentList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
|   | ||||
							
								
								
									
										105
									
								
								cmd/base/command.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								cmd/base/command.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,105 @@ | ||||
| // Copyright 2025 The Gitea Authors. All rights reserved. | ||||
| // SPDX-License-Identifier: MIT | ||||
|  | ||||
| package base | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"log" | ||||
| 	"os" | ||||
|  | ||||
| 	"code.gitea.io/tea/modules/config" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
|  | ||||
| 	gogit "github.com/go-git/go-git/v5" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
|  | ||||
| // InitCommand resolves the application context, and returns the active login, and if | ||||
| // available the repo slug. It does this by reading the config file for logins, parsing | ||||
| // the remotes of the .git repo specified in repoFlag or $PWD, and using overrides from | ||||
| // command flags. If a local git repo can't be found, repo slug values are unset. | ||||
| func InitCommand(cmd *cli.Command) *context.TeaContext { | ||||
| 	// these flags are used as overrides to the context detection via local git repo | ||||
| 	repoFlag := cmd.String("repo") | ||||
| 	loginFlag := cmd.String("login") | ||||
| 	remoteFlag := cmd.String("remote") | ||||
|  | ||||
| 	var ( | ||||
| 		c                  context.TeaContext | ||||
| 		err                error | ||||
| 		repoPath           string // empty means PWD | ||||
| 		repoFlagPathExists bool | ||||
| 	) | ||||
|  | ||||
| 	// check if repoFlag can be interpreted as path to local repo. | ||||
| 	if len(repoFlag) != 0 { | ||||
| 		if repoFlagPathExists, err = utils.DirExists(repoFlag); err != nil { | ||||
| 			log.Fatal(err.Error()) | ||||
| 		} | ||||
| 		if repoFlagPathExists { | ||||
| 			repoPath = repoFlag | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if len(remoteFlag) == 0 { | ||||
| 		remoteFlag = config.GetPreferences().FlagDefaults.Remote | ||||
| 	} | ||||
|  | ||||
| 	if repoPath == "" { | ||||
| 		if repoPath, err = os.Getwd(); err != nil { | ||||
| 			log.Fatal(err.Error()) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// try to read local git repo & extract context: if repoFlag specifies a valid path, read repo in that dir, | ||||
| 	// otherwise attempt PWD. if no repo is found, continue with default login | ||||
| 	if c.LocalRepo, c.Login, c.RepoSlug, err = context.ContextFromLocalRepo(repoPath, remoteFlag); err != nil { | ||||
| 		if err == context.ErrNotAGiteaRepo || err == gogit.ErrRepositoryNotExists { | ||||
| 			// we can deal with that, commands needing the optional values use ctx.Ensure() | ||||
| 		} else { | ||||
| 			log.Fatal(err.Error()) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if len(repoFlag) != 0 && !repoFlagPathExists { | ||||
| 		// if repoFlag is not a valid path, use it to override repoSlug | ||||
| 		c.RepoSlug = repoFlag | ||||
| 	} | ||||
|  | ||||
| 	// override config user with env variable | ||||
| 	envLogin := context.GetLoginByEnvVar() | ||||
| 	if envLogin != nil { | ||||
| 		_, err := utils.ValidateAuthenticationMethod(envLogin.URL, envLogin.Token, "", "", false, "", "") | ||||
| 		if err != nil { | ||||
| 			log.Fatal(err.Error()) | ||||
| 		} | ||||
| 		c.Login = envLogin | ||||
| 	} | ||||
|  | ||||
| 	// override login from flag, or use default login if repo based detection failed | ||||
| 	if len(loginFlag) != 0 { | ||||
| 		c.Login = config.GetLoginByName(loginFlag) | ||||
| 		if c.Login == nil { | ||||
| 			log.Fatalf("Login name '%s' does not exist", loginFlag) | ||||
| 		} | ||||
| 	} else if c.Login == nil { | ||||
| 		c.Login, err = interact.LoginSelect() | ||||
| 		if err != nil { | ||||
| 			// TODO: maybe we can directly start interact.CreateLogin() (only if | ||||
| 			// we're sure we can interactively!), as gh cli does. | ||||
| 			fmt.Println(`No gitea login configured. To start using tea, first run | ||||
|   tea login add | ||||
| and then run your command again.`) | ||||
| 			os.Exit(1) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// parse reposlug (owner falling back to login owner if reposlug contains only repo name) | ||||
| 	c.Owner, c.Repo = utils.GetOwnerAndRepo(c.RepoSlug, c.Login.User) | ||||
| 	c.Command = cmd | ||||
| 	c.Output = cmd.String("output") | ||||
| 	return &c | ||||
| } | ||||
| @@ -6,6 +6,7 @@ package branches | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| @@ -38,7 +39,7 @@ var CmdBranchesList = cli.Command{ | ||||
|  | ||||
| // RunBranchesList list branches | ||||
| func RunBranchesList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	owner := ctx.Owner | ||||
| @@ -52,7 +53,6 @@ func RunBranchesList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	branches, _, err = ctx.Login.Client().ListRepoBranches(owner, ctx.Repo, gitea.ListRepoBranchesOptions{ | ||||
| 		ListOptions: flags.GetListOptions(), | ||||
| 	}) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| @@ -60,7 +60,6 @@ func RunBranchesList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	protections, _, err = ctx.Login.Client().ListBranchProtections(owner, ctx.Repo, gitea.ListBranchProtectionsOptions{ | ||||
| 		ListOptions: flags.GetListOptions(), | ||||
| 	}) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
|  | ||||
| @@ -45,7 +46,7 @@ var CmdBranchesUnprotect = cli.Command{ | ||||
|  | ||||
| // RunBranchesProtect function to protect/unprotect a list of branches | ||||
| func RunBranchesProtect(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	if !cmd.Args().Present() { | ||||
|   | ||||
| @@ -7,9 +7,9 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/config" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/debug" | ||||
| 	"code.gitea.io/tea/modules/git" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| @@ -48,7 +48,7 @@ When a host is specified in the repo-slug, it will override the login specified | ||||
| } | ||||
|  | ||||
| func runRepoClone(ctx stdctx.Context, cmd *cli.Command) error { | ||||
| 	teaCmd := context.InitCommand(cmd) | ||||
| 	teaCmd := base.InitCommand(cmd) | ||||
|  | ||||
| 	args := teaCmd.Args() | ||||
| 	if args.Len() < 1 { | ||||
|   | ||||
| @@ -10,6 +10,7 @@ import ( | ||||
| 	"io" | ||||
| 	"strings" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/config" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| @@ -36,7 +37,7 @@ var CmdAddComment = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runAddComment(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	args := ctx.Args() | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/issues" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| @@ -48,7 +49,7 @@ func runIssues(ctx stdctx.Context, cmd *cli.Command) error { | ||||
| } | ||||
|  | ||||
| func runIssueDetail(_ stdctx.Context, cmd *cli.Command, index string) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	idx, err := utils.ArgToIndex(index) | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| @@ -23,7 +24,7 @@ var CmdIssuesClose = cli.Command{ | ||||
| 	Description: `Change state of one ore more issues to 'closed'`, | ||||
| 	ArgsUsage:   "<issue index> [<issue index>...]", | ||||
| 	Action: func(ctx stdctx.Context, cmd *cli.Command) error { | ||||
| 		var s = gitea.StateClosed | ||||
| 		s := gitea.StateClosed | ||||
| 		return editIssueState(ctx, cmd, gitea.EditIssueOption{State: &s}) | ||||
| 	}, | ||||
| 	Flags: flags.AllDefaultFlags, | ||||
| @@ -31,7 +32,7 @@ var CmdIssuesClose = cli.Command{ | ||||
|  | ||||
| // editIssueState abstracts the arg parsing to edit the given issue | ||||
| func editIssueState(_ stdctx.Context, cmd *cli.Command, opts gitea.EditIssueOption) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	if ctx.Args().Len() == 0 { | ||||
| 		return fmt.Errorf(ctx.Command.ArgsUsage) | ||||
|   | ||||
| @@ -6,6 +6,7 @@ package issues | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| @@ -26,7 +27,7 @@ var CmdIssuesCreate = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runIssuesCreate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	if ctx.NumFlags() == 0 { | ||||
|   | ||||
| @@ -8,6 +8,7 @@ import ( | ||||
|  | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| @@ -30,7 +31,7 @@ use an empty string (eg. --milestone "").`, | ||||
| } | ||||
|  | ||||
| func runIssuesEdit(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	if !cmd.Args().Present() { | ||||
|   | ||||
| @@ -8,8 +8,8 @@ import ( | ||||
| 	"fmt" | ||||
| 	"time" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| @@ -34,7 +34,7 @@ var CmdIssuesList = cli.Command{ | ||||
|  | ||||
| // RunIssuesList list issues | ||||
| func RunIssuesList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
|  | ||||
| 	state := gitea.StateOpen | ||||
| 	switch ctx.String("state") { | ||||
| @@ -97,7 +97,6 @@ func RunIssuesList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 			Since:       from, | ||||
| 			Before:      until, | ||||
| 		}) | ||||
|  | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| @@ -116,7 +115,6 @@ func RunIssuesList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 			Before:      until, | ||||
| 			Owner:       owner, | ||||
| 		}) | ||||
|  | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
|   | ||||
| @@ -10,6 +10,7 @@ import ( | ||||
| 	"os" | ||||
| 	"strings" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
|  | ||||
| @@ -46,7 +47,7 @@ var CmdLabelCreate = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runLabelCreate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	labelFile := ctx.String("file") | ||||
| @@ -65,7 +66,7 @@ func runLabelCreate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		defer f.Close() | ||||
|  | ||||
| 		scanner := bufio.NewScanner(f) | ||||
| 		var i = 1 | ||||
| 		i := 1 | ||||
| 		for scanner.Scan() { | ||||
| 			line := scanner.Text() | ||||
| 			color, name, description := splitLabelLine(line) | ||||
|   | ||||
| @@ -6,6 +6,7 @@ package labels | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
|  | ||||
| @@ -29,7 +30,7 @@ var CmdLabelDelete = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runLabelDelete(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	_, err := ctx.Login.Client().DeleteLabel(ctx.Owner, ctx.Repo, ctx.Int64("id")) | ||||
|   | ||||
| @@ -6,6 +6,7 @@ package labels | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| @@ -36,7 +37,7 @@ var CmdLabelsList = cli.Command{ | ||||
|  | ||||
| // RunLabelsList list labels. | ||||
| func RunLabelsList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	client := ctx.Login.Client() | ||||
|   | ||||
| @@ -6,6 +6,7 @@ package labels | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
|  | ||||
| @@ -41,7 +42,7 @@ var CmdLabelUpdate = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runLabelUpdate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	id := ctx.Int64("id") | ||||
| @@ -67,7 +68,6 @@ func runLabelUpdate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		Color:       pColor, | ||||
| 		Description: pDescription, | ||||
| 	}) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
| @@ -6,6 +6,7 @@ package cmd | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/milestones" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| @@ -40,7 +41,7 @@ func runMilestones(ctx stdctx.Context, cmd *cli.Command) error { | ||||
| } | ||||
|  | ||||
| func runMilestoneDetail(_ stdctx.Context, cmd *cli.Command, name string) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
|   | ||||
| @@ -9,8 +9,8 @@ import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| 	"code.gitea.io/tea/modules/task" | ||||
| 	"github.com/araddon/dateparse" | ||||
| @@ -50,7 +50,7 @@ var CmdMilestonesCreate = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runMilestonesCreate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
|  | ||||
| 	date := ctx.String("deadline") | ||||
| 	deadline := &time.Time{} | ||||
|   | ||||
| @@ -6,6 +6,7 @@ package milestones | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
|  | ||||
| @@ -24,7 +25,7 @@ var CmdMilestonesDelete = cli.Command{ | ||||
| } | ||||
|  | ||||
| func deleteMilestone(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
|   | ||||
| @@ -9,6 +9,7 @@ import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| @@ -71,7 +72,7 @@ var CmdMilestoneRemoveIssue = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runMilestoneIssueList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
| @@ -121,7 +122,7 @@ func runMilestoneIssueList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| } | ||||
|  | ||||
| func runMilestoneIssueAdd(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	client := ctx.Login.Client() | ||||
| 	if ctx.Args().Len() != 2 { | ||||
| @@ -148,7 +149,7 @@ func runMilestoneIssueAdd(_ stdctx.Context, cmd *cli.Command) error { | ||||
| } | ||||
|  | ||||
| func runMilestoneIssueRemove(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	client := ctx.Login.Client() | ||||
| 	if ctx.Args().Len() != 2 { | ||||
|   | ||||
| @@ -6,6 +6,7 @@ package milestones | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| @@ -40,7 +41,7 @@ var CmdMilestonesList = cli.Command{ | ||||
|  | ||||
| // RunMilestonesList list milestones | ||||
| func RunMilestonesList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	fields, err := fieldsFlag.GetValues(cmd) | ||||
| @@ -64,7 +65,6 @@ func RunMilestonesList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		ListOptions: flags.GetListOptions(), | ||||
| 		State:       state, | ||||
| 	}) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| @@ -29,7 +30,7 @@ var CmdMilestonesReopen = cli.Command{ | ||||
| } | ||||
|  | ||||
| func editMilestoneStatus(_ stdctx.Context, cmd *cli.Command, close bool) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	if ctx.Args().Len() == 0 { | ||||
| 		return fmt.Errorf(ctx.Command.ArgsUsage) | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"log" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| @@ -64,7 +65,7 @@ func listNotifications(_ stdctx.Context, cmd *cli.Command, status []gitea.Notify | ||||
| 	var news []*gitea.NotificationThread | ||||
| 	var err error | ||||
|  | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	client := ctx.Login.Client() | ||||
| 	all := ctx.Bool("mine") | ||||
|  | ||||
|   | ||||
| @@ -8,6 +8,7 @@ import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
| @@ -23,7 +24,7 @@ var CmdNotificationsMarkRead = cli.Command{ | ||||
| 	ArgsUsage:   "[all | <notification id>]", | ||||
| 	Flags:       flags.NotificationFlags, | ||||
| 	Action: func(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		ctx := context.InitCommand(cmd) | ||||
| 		ctx := base.InitCommand(cmd) | ||||
| 		filter, err := flags.NotificationStateFlag.GetValues(cmd) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| @@ -44,7 +45,7 @@ var CmdNotificationsMarkUnread = cli.Command{ | ||||
| 	ArgsUsage:   "[all | <notification id>]", | ||||
| 	Flags:       flags.NotificationFlags, | ||||
| 	Action: func(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		ctx := context.InitCommand(cmd) | ||||
| 		ctx := base.InitCommand(cmd) | ||||
| 		filter, err := flags.NotificationStateFlag.GetValues(cmd) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| @@ -65,7 +66,7 @@ var CmdNotificationsMarkPinned = cli.Command{ | ||||
| 	ArgsUsage:   "[all | <notification id>]", | ||||
| 	Flags:       flags.NotificationFlags, | ||||
| 	Action: func(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		ctx := context.InitCommand(cmd) | ||||
| 		ctx := base.InitCommand(cmd) | ||||
| 		filter, err := flags.NotificationStateFlag.GetValues(cmd) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| @@ -85,7 +86,7 @@ var CmdNotificationsUnpin = cli.Command{ | ||||
| 	ArgsUsage:   "[all | <notification id>]", | ||||
| 	Flags:       flags.NotificationFlags, | ||||
| 	Action: func(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		ctx := context.InitCommand(cmd) | ||||
| 		ctx := base.InitCommand(cmd) | ||||
| 		filter := []string{string(gitea.NotifyStatusPinned)} | ||||
| 		// NOTE: we implicitly mark it as read, to match web UI semantics. marking as unread might be more useful? | ||||
| 		return markNotificationAs(ctx, filter, gitea.NotifyStatusRead) | ||||
|   | ||||
| @@ -8,6 +8,7 @@ import ( | ||||
| 	"path" | ||||
| 	"strings" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	local_git "code.gitea.io/tea/modules/git" | ||||
| @@ -28,7 +29,7 @@ var CmdOpen = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runOpen(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	var suffix string | ||||
|   | ||||
| @@ -6,6 +6,7 @@ package cmd | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/organizations" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| @@ -31,7 +32,7 @@ var CmdOrgs = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runOrganizations(ctx stdctx.Context, cmd *cli.Command) error { | ||||
| 	teaCtx := context.InitCommand(cmd) | ||||
| 	teaCtx := base.InitCommand(cmd) | ||||
| 	if teaCtx.Args().Len() == 1 { | ||||
| 		return runOrganizationDetail(teaCtx) | ||||
| 	} | ||||
|   | ||||
| @@ -9,8 +9,8 @@ import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
| @@ -53,7 +53,7 @@ var CmdOrganizationCreate = cli.Command{ | ||||
|  | ||||
| // RunOrganizationCreate sets up a new organization | ||||
| func RunOrganizationCreate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
|  | ||||
| 	if ctx.Args().Len() < 1 { | ||||
| 		return fmt.Errorf("You have to specify the organization name you want to create") | ||||
|   | ||||
| @@ -7,8 +7,8 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
|  | ||||
| @@ -28,7 +28,7 @@ var CmdOrganizationDelete = cli.Command{ | ||||
|  | ||||
| // RunOrganizationDelete delete user organization | ||||
| func RunOrganizationDelete(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
|  | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
|   | ||||
| @@ -7,8 +7,8 @@ import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
| @@ -29,7 +29,7 @@ var CmdOrganizationList = cli.Command{ | ||||
|  | ||||
| // RunOrganizationList list user organizations | ||||
| func RunOrganizationList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
| 	userOrganizations, _, err := client.ListUserOrgs(ctx.Login.User, gitea.ListOrgsOptions{ | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/pulls" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| @@ -55,7 +56,7 @@ func runPulls(ctx stdctx.Context, cmd *cli.Command) error { | ||||
| } | ||||
|  | ||||
| func runPullDetail(_ stdctx.Context, cmd *cli.Command, index string) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	idx, err := utils.ArgToIndex(index) | ||||
| 	if err != nil { | ||||
|   | ||||
| @@ -10,6 +10,7 @@ import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/task" | ||||
| @@ -25,7 +26,7 @@ var CmdPullsApprove = cli.Command{ | ||||
| 	Description: "Approve a pull request", | ||||
| 	ArgsUsage:   "<pull index> [<comment>]", | ||||
| 	Action: func(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		ctx := context.InitCommand(cmd) | ||||
| 		ctx := base.InitCommand(cmd) | ||||
| 		ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 		if ctx.Args().Len() == 0 { | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| @@ -34,7 +35,7 @@ var CmdPullsCheckout = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runPullsCheckout(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{ | ||||
| 		LocalRepo:  true, | ||||
| 		RemoteRepo: true, | ||||
|   | ||||
| @@ -8,6 +8,7 @@ import ( | ||||
|  | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| @@ -32,7 +33,7 @@ var CmdPullsClean = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runPullsClean(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{LocalRepo: true}) | ||||
| 	if ctx.Args().Len() != 1 { | ||||
| 		return fmt.Errorf("Must specify a PR index") | ||||
|   | ||||
| @@ -7,8 +7,8 @@ import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| 	"code.gitea.io/tea/modules/task" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| @@ -41,7 +41,7 @@ var CmdPullsCreate = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runPullsCreate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
|  | ||||
| 	// no args -> interactive mode | ||||
| 	if ctx.NumFlags() == 0 { | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
| @@ -17,7 +18,7 @@ import ( | ||||
|  | ||||
| // editPullState abstracts the arg parsing to edit the given pull request | ||||
| func editPullState(_ stdctx.Context, cmd *cli.Command, opts gitea.EditPullRequestOption) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	if ctx.Args().Len() == 0 { | ||||
| 		return fmt.Errorf("Please provide a Pull Request index") | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| @@ -30,7 +31,7 @@ var CmdPullsList = cli.Command{ | ||||
|  | ||||
| // RunPullsList return list of pulls | ||||
| func RunPullsList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	state := gitea.StateOpen | ||||
| @@ -46,7 +47,6 @@ func RunPullsList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	prs, _, err := ctx.Login.Client().ListRepoPullRequests(ctx.Owner, ctx.Repo, gitea.ListPullRequestsOptions{ | ||||
| 		State: state, | ||||
| 	}) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| @@ -41,7 +42,7 @@ var CmdPullsMerge = cli.Command{ | ||||
| 		}, | ||||
| 	}, flags.AllDefaultFlags...), | ||||
| 	Action: func(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		ctx := context.InitCommand(cmd) | ||||
| 		ctx := base.InitCommand(cmd) | ||||
| 		ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 		if ctx.Args().Len() != 1 { | ||||
|   | ||||
| @@ -8,6 +8,7 @@ import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/task" | ||||
| @@ -24,7 +25,7 @@ var CmdPullsReject = cli.Command{ | ||||
| 	Description: "Request changes to a pull request", | ||||
| 	ArgsUsage:   "<pull index> <reason>", | ||||
| 	Action: func(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		ctx := context.InitCommand(cmd) | ||||
| 		ctx := base.InitCommand(cmd) | ||||
| 		ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 		if ctx.Args().Len() < 2 { | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| @@ -22,7 +23,7 @@ var CmdPullsReview = cli.Command{ | ||||
| 	Description: "Interactively review a pull request", | ||||
| 	ArgsUsage:   "<pull index>", | ||||
| 	Action: func(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		ctx := context.InitCommand(cmd) | ||||
| 		ctx := base.InitCommand(cmd) | ||||
| 		ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 		if ctx.Args().Len() != 1 { | ||||
|   | ||||
| @@ -10,6 +10,7 @@ import ( | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
|  | ||||
| @@ -68,7 +69,7 @@ var CmdReleaseCreate = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runReleaseCreate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	tag := ctx.String("tag") | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
|  | ||||
| @@ -35,7 +36,7 @@ var CmdReleaseDelete = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runReleaseDelete(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
|   | ||||
| @@ -10,6 +10,7 @@ import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| @@ -58,7 +59,7 @@ var CmdReleaseEdit = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runReleaseEdit(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| @@ -31,7 +32,7 @@ var CmdReleaseList = cli.Command{ | ||||
|  | ||||
| // RunReleasesList list releases | ||||
| func RunReleasesList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	releases, _, err := ctx.Login.Client().ListReleases(ctx.Owner, ctx.Repo, gitea.ListReleasesOptions{ | ||||
|   | ||||
| @@ -6,8 +6,8 @@ package cmd | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/repos" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
|  | ||||
| @@ -44,7 +44,7 @@ func runRepos(ctx stdctx.Context, cmd *cli.Command) error { | ||||
| } | ||||
|  | ||||
| func runRepoDetail(_ stdctx.Context, cmd *cli.Command, path string) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	client := ctx.Login.Client() | ||||
| 	repoOwner, repoName := utils.GetOwnerAndRepo(path, ctx.Owner) | ||||
| 	repo, _, err := client.GetRepo(repoOwner, repoName) | ||||
|   | ||||
| @@ -7,8 +7,8 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| @@ -103,7 +103,7 @@ var CmdRepoCreate = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runRepoCreate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	client := ctx.Login.Client() | ||||
| 	var ( | ||||
| 		repo       *gitea.Repository | ||||
|   | ||||
| @@ -9,8 +9,8 @@ import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| @@ -83,7 +83,7 @@ var CmdRepoCreateFromTemplate = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runRepoCreateFromTemplate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
| 	templateOwner, templateRepo := utils.GetOwnerAndRepo(ctx.String("template"), ctx.Login.User) | ||||
|   | ||||
| @@ -7,8 +7,8 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
|  | ||||
| 	"github.com/charmbracelet/huh" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| @@ -46,7 +46,7 @@ var CmdRepoRm = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runRepoDelete(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
|  | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| @@ -33,7 +34,7 @@ var CmdRepoFork = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runRepoFork(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
|   | ||||
| @@ -6,8 +6,8 @@ package repos | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| @@ -50,7 +50,7 @@ var CmdReposList = cli.Command{ | ||||
|  | ||||
| // RunReposList list repositories | ||||
| func RunReposList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	teaCmd := context.InitCommand(cmd) | ||||
| 	teaCmd := base.InitCommand(cmd) | ||||
| 	client := teaCmd.Login.Client() | ||||
|  | ||||
| 	typeFilter, err := getTypeFilter(cmd) | ||||
|   | ||||
| @@ -9,8 +9,8 @@ import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
| @@ -109,7 +109,7 @@ var CmdRepoMigrate = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runRepoMigrate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	client := ctx.Login.Client() | ||||
| 	var ( | ||||
| 		repo    *gitea.Repository | ||||
| @@ -157,7 +157,6 @@ func runRepoMigrate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	} | ||||
|  | ||||
| 	repo, _, err = client.MigrateRepo(opts) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
| @@ -8,8 +8,8 @@ import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| @@ -57,7 +57,7 @@ var CmdReposSearch = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runReposSearch(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	teaCmd := context.InitCommand(cmd) | ||||
| 	teaCmd := base.InitCommand(cmd) | ||||
| 	client := teaCmd.Login.Client() | ||||
|  | ||||
| 	var ownerID int64 | ||||
|   | ||||
| @@ -9,6 +9,7 @@ import ( | ||||
| 	"strings" | ||||
| 	"time" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
| @@ -32,7 +33,7 @@ var CmdTrackedTimesAdd = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runTrackedTimesAdd(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
| 	if ctx.Args().Len() < 2 { | ||||
|   | ||||
| @@ -8,6 +8,7 @@ import ( | ||||
| 	"fmt" | ||||
| 	"strconv" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
| @@ -26,7 +27,7 @@ var CmdTrackedTimesDelete = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runTrackedTimesDelete(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
|   | ||||
| @@ -9,6 +9,7 @@ import ( | ||||
| 	"strings" | ||||
| 	"time" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| @@ -70,7 +71,7 @@ Depending on your permissions on the repository, only your own tracked times mig | ||||
|  | ||||
| // RunTimesList list repositories | ||||
| func RunTimesList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
| @@ -25,7 +26,7 @@ var CmdTrackedTimesReset = cli.Command{ | ||||
| } | ||||
|  | ||||
| func runTrackedTimesReset(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx := base.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,7 @@ package cmd | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/cmd/base" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
| @@ -19,7 +19,7 @@ var CmdWhoami = cli.Command{ | ||||
| 	Usage:       "Show current logged in user", | ||||
| 	ArgsUsage:   " ", // command does not accept arguments | ||||
| 	Action: func(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		ctx := context.InitCommand(cmd) | ||||
| 		ctx := base.InitCommand(cmd) | ||||
| 		client := ctx.Login.Client() | ||||
| 		user, _, _ := client.GetMyUserInfo() | ||||
| 		print.UserDetails(user) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Lunny Xiao
					Lunny Xiao