Add more flags to tea repo create
#409
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user