mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-03 02:18:30 +02:00
feat: add validation for object-format flag in repo create command
This commit is contained in:
@ -87,6 +87,10 @@ var CmdRepoCreate = cli.Command{
|
||||
Name: "trustmodel",
|
||||
Usage: "select trust model (committer,collaborator,collaborator+committer)",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "object-format",
|
||||
Usage: "select git object format (sha1,sha256)",
|
||||
},
|
||||
}, flags.LoginOutputFlags...),
|
||||
}
|
||||
|
||||
@ -112,18 +116,26 @@ func runRepoCreate(cmd *cli.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
if ctx.IsSet("object-format") {
|
||||
format := ctx.String("object-format")
|
||||
if format != "sha1" && format != "sha256" {
|
||||
return fmt.Errorf("invalid object format '%s', must be either 'sha1' or 'sha256'", format)
|
||||
}
|
||||
}
|
||||
|
||||
opts := gitea.CreateRepoOption{
|
||||
Name: ctx.String("name"),
|
||||
Description: ctx.String("description"),
|
||||
Private: ctx.Bool("private"),
|
||||
AutoInit: ctx.Bool("init"),
|
||||
IssueLabels: ctx.String("labels"),
|
||||
Gitignores: ctx.String("gitignores"),
|
||||
License: ctx.String("license"),
|
||||
Readme: ctx.String("readme"),
|
||||
DefaultBranch: ctx.String("branch"),
|
||||
Template: ctx.Bool("template"),
|
||||
TrustModel: trustmodel,
|
||||
Name: ctx.String("name"),
|
||||
Description: ctx.String("description"),
|
||||
Private: ctx.Bool("private"),
|
||||
AutoInit: ctx.Bool("init"),
|
||||
IssueLabels: ctx.String("labels"),
|
||||
Gitignores: ctx.String("gitignores"),
|
||||
License: ctx.String("license"),
|
||||
Readme: ctx.String("readme"),
|
||||
DefaultBranch: ctx.String("branch"),
|
||||
Template: ctx.Bool("template"),
|
||||
TrustModel: trustmodel,
|
||||
ObjectFormatName: ctx.String("object-format"),
|
||||
}
|
||||
if len(ctx.String("owner")) != 0 {
|
||||
repo, _, err = client.CreateOrgRepo(ctx.String("owner"), opts)
|
||||
|
Reference in New Issue
Block a user