mirror of
				https://gitea.com/gitea/tea.git
				synced 2025-10-30 16:55:25 +01:00 
			
		
		
		
	Add more flags to tea repo create (#409)
				
					
				
			adds the `--template` and `--trustmodel` flags Co-authored-by: Norwin <git@nroo.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/409 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Norwin <noerw@noreply.gitea.io> Co-committed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
		| @@ -79,6 +79,14 @@ var CmdRepoCreate = cli.Command{ | |||||||
| 			Required: false, | 			Required: false, | ||||||
| 			Usage:    "use custom default branch (need --init)", | 			Usage:    "use custom default branch (need --init)", | ||||||
| 		}, | 		}, | ||||||
|  | 		&cli.BoolFlag{ | ||||||
|  | 			Name:  "template", | ||||||
|  | 			Usage: "make repo a template repo", | ||||||
|  | 		}, | ||||||
|  | 		&cli.StringFlag{ | ||||||
|  | 			Name:  "trustmodel", | ||||||
|  | 			Usage: "select trust model (committer,collaborator,collaborator+committer)", | ||||||
|  | 		}, | ||||||
| 	}, flags.LoginOutputFlags...), | 	}, flags.LoginOutputFlags...), | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -86,9 +94,24 @@ func runRepoCreate(cmd *cli.Context) error { | |||||||
| 	ctx := context.InitCommand(cmd) | 	ctx := context.InitCommand(cmd) | ||||||
| 	client := ctx.Login.Client() | 	client := ctx.Login.Client() | ||||||
| 	var ( | 	var ( | ||||||
| 		repo *gitea.Repository | 		repo       *gitea.Repository | ||||||
| 		err  error | 		err        error | ||||||
|  | 		trustmodel gitea.TrustModel | ||||||
| 	) | 	) | ||||||
|  |  | ||||||
|  | 	if ctx.IsSet("trustmodel") { | ||||||
|  | 		switch ctx.String("trustmodel") { | ||||||
|  | 		case "committer": | ||||||
|  | 			trustmodel = gitea.TrustModelCommitter | ||||||
|  | 		case "collaborator": | ||||||
|  | 			trustmodel = gitea.TrustModelCollaborator | ||||||
|  | 		case "collaborator+committer": | ||||||
|  | 			trustmodel = gitea.TrustModelCollaboratorCommitter | ||||||
|  | 		default: | ||||||
|  | 			return fmt.Errorf("unknown trustmodel type '%s'", ctx.String("trustmodel")) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	opts := gitea.CreateRepoOption{ | 	opts := gitea.CreateRepoOption{ | ||||||
| 		Name:          ctx.String("name"), | 		Name:          ctx.String("name"), | ||||||
| 		Description:   ctx.String("description"), | 		Description:   ctx.String("description"), | ||||||
| @@ -99,6 +122,8 @@ func runRepoCreate(cmd *cli.Context) error { | |||||||
| 		License:       ctx.String("license"), | 		License:       ctx.String("license"), | ||||||
| 		Readme:        ctx.String("readme"), | 		Readme:        ctx.String("readme"), | ||||||
| 		DefaultBranch: ctx.String("branch"), | 		DefaultBranch: ctx.String("branch"), | ||||||
|  | 		Template:      ctx.Bool("template"), | ||||||
|  | 		TrustModel:    trustmodel, | ||||||
| 	} | 	} | ||||||
| 	if len(ctx.String("owner")) != 0 { | 	if len(ctx.String("owner")) != 0 { | ||||||
| 		repo, _, err = client.CreateOrgRepo(ctx.String("owner"), opts) | 		repo, _, err = client.CreateOrgRepo(ctx.String("owner"), opts) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Norwin
					Norwin