mirror of
				https://gitea.com/gitea/tea.git
				synced 2025-10-31 01:05:26 +01:00 
			
		
		
		
	 root360-AndreasUlm
					root360-AndreasUlm
				
			
				
					committed by
					
						 techknowlogick
						techknowlogick
					
				
			
			
				
	
			
			
			 techknowlogick
						techknowlogick
					
				
			
						parent
						
							bbcc689b93
						
					
				
				
					commit
					7df0354d6c
				
			| @@ -26,21 +26,7 @@ var CmdIssues = cli.Command{ | ||||
| 		CmdIssuesList, | ||||
| 		CmdIssuesCreate, | ||||
| 	}, | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 			Name:  "login, l", | ||||
| 			Usage: "Indicate one login, optional when inside a gitea repository", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 			Name:  "repo, r", | ||||
| 			Usage: "Indicate one repository, optional when inside a gitea repository", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 			Name:        "output, o", | ||||
| 			Usage:       outputUsage, | ||||
| 			Destination: &output, | ||||
| 		}, | ||||
| 	}, | ||||
| 	Flags: AllDefaultFlags, | ||||
| } | ||||
|  | ||||
| // CmdIssuesList represents a sub command of issues to list issues | ||||
| @@ -49,6 +35,7 @@ var CmdIssuesList = cli.Command{ | ||||
| 	Usage:       "List issues of the repository", | ||||
| 	Description: `List issues of the repository`, | ||||
| 	Action:      runIssuesList, | ||||
| 	Flags:       AllDefaultFlags, | ||||
| } | ||||
|  | ||||
| func runIssues(ctx *cli.Context) error { | ||||
| @@ -59,7 +46,7 @@ func runIssues(ctx *cli.Context) error { | ||||
| } | ||||
|  | ||||
| func runIssueDetail(ctx *cli.Context, index string) error { | ||||
| 	login, owner, repo := initCommand(ctx) | ||||
| 	login, owner, repo := initCommand() | ||||
|  | ||||
| 	if strings.HasPrefix(index, "#") { | ||||
| 		index = index[1:] | ||||
| @@ -85,7 +72,7 @@ func runIssueDetail(ctx *cli.Context, index string) error { | ||||
| } | ||||
|  | ||||
| func runIssuesList(ctx *cli.Context) error { | ||||
| 	login, owner, repo := initCommand(ctx) | ||||
| 	login, owner, repo := initCommand() | ||||
|  | ||||
| 	issues, err := login.Client().ListRepoIssues(owner, repo, gitea.ListIssueOption{ | ||||
| 		Page:  0, | ||||
| @@ -136,7 +123,7 @@ var CmdIssuesCreate = cli.Command{ | ||||
| 	Usage:       "Create an issue on repository", | ||||
| 	Description: `Create an issue on repository`, | ||||
| 	Action:      runIssuesCreate, | ||||
| 	Flags: []cli.Flag{ | ||||
| 	Flags: append([]cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 			Name:  "title, t", | ||||
| 			Usage: "issue title to create", | ||||
| @@ -145,50 +132,11 @@ var CmdIssuesCreate = cli.Command{ | ||||
| 			Name:  "body, b", | ||||
| 			Usage: "issue body to create", | ||||
| 		}, | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| func initCommand(ctx *cli.Context) (*Login, string, string) { | ||||
| 	err := loadConfig(yamlConfigPath) | ||||
| 	if err != nil { | ||||
| 		log.Fatal("load config file failed", yamlConfigPath) | ||||
| 	} | ||||
|  | ||||
| 	var login *Login | ||||
| 	if loginFlag := getGlobalFlag(ctx, "login"); loginFlag == "" { | ||||
| 		login, err = getActiveLogin() | ||||
| 		if err != nil { | ||||
| 			log.Fatal(err) | ||||
| 		} | ||||
| 	} else { | ||||
| 		login = getLoginByName(loginFlag) | ||||
| 		if login == nil { | ||||
| 			log.Fatal("indicated login name", loginFlag, "does not exist") | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	repoPath := getGlobalFlag(ctx, "repo") | ||||
| 	if repoPath == "" { | ||||
| 		login, repoPath, err = curGitRepoPath() | ||||
| 		if err != nil { | ||||
| 			log.Fatal(err.Error()) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	owner, repo := splitRepo(repoPath) | ||||
| 	return login, owner, repo | ||||
| } | ||||
|  | ||||
| func getGlobalFlag(ctx *cli.Context, flag string) string { | ||||
| 	var val = ctx.String(flag) | ||||
| 	if val == "" { | ||||
| 		return ctx.GlobalString(flag) | ||||
| 	} | ||||
| 	return val | ||||
| 	}, LoginRepoFlags...), | ||||
| } | ||||
|  | ||||
| func runIssuesCreate(ctx *cli.Context) error { | ||||
| 	login, owner, repo := initCommand(ctx) | ||||
| 	login, owner, repo := initCommand() | ||||
|  | ||||
| 	_, err := login.Client().CreateIssue(owner, repo, gitea.CreateIssueOption{ | ||||
| 		Title: ctx.String("title"), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user