mirror of
https://gitea.com/gitea/tea
synced 2024-11-23 00:12:05 +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:
parent
3cf084cb96
commit
7a05be436c
@ -79,6 +79,14 @@ var CmdRepoCreate = cli.Command{
|
||||
Required: false,
|
||||
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...),
|
||||
}
|
||||
|
||||
@ -86,9 +94,24 @@ func runRepoCreate(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
client := ctx.Login.Client()
|
||||
var (
|
||||
repo *gitea.Repository
|
||||
err error
|
||||
repo *gitea.Repository
|
||||
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{
|
||||
Name: ctx.String("name"),
|
||||
Description: ctx.String("description"),
|
||||
@ -99,6 +122,8 @@ func runRepoCreate(cmd *cli.Context) error {
|
||||
License: ctx.String("license"),
|
||||
Readme: ctx.String("readme"),
|
||||
DefaultBranch: ctx.String("branch"),
|
||||
Template: ctx.Bool("template"),
|
||||
TrustModel: trustmodel,
|
||||
}
|
||||
if len(ctx.String("owner")) != 0 {
|
||||
repo, _, err = client.CreateOrgRepo(ctx.String("owner"), opts)
|
||||
|
Loading…
Reference in New Issue
Block a user