@@ -2,6 +2,7 @@ package cmd
22
33import (
44 "github.com/fatih/color"
5+ "github.com/google/go-github/github"
56 "github.com/hellofresh/github-cli/pkg/pullapprove"
67 "github.com/hellofresh/github-cli/pkg/repo"
78 "github.com/pkg/errors"
2223 HasDefaultLabels bool
2324 HasWebhooks bool
2425 HasBranchProtections bool
26+ HasIssues bool
27+ HasWiki bool
28+ HasPages bool
2529 }
2630)
2731
@@ -34,28 +38,32 @@ func init() {
3438 createRepoCmd .Flags ().StringVarP (& createRepoFlags .Description , "description" , "d" , "" , "The repository's description" )
3539 createRepoCmd .Flags ().StringVarP (& createRepoFlags .Org , "organization" , "o" , "" , "Github's organization" )
3640 createRepoCmd .Flags ().BoolVar (& createRepoFlags .Private , "private" , true , "Is the repository private?" )
37- createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasPullApprove , "add-pullapprove" , true , "Enables pull approve" )
38- createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasTeams , "add-teams" , true , "Enable teams" )
39- createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasLabels , "add-labels" , true , "Enable labels" )
40- createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasDefaultLabels , "add-default-labels" , true , "Removes the default github labels" )
41- createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasWebhooks , "add-webhooks" , true , "Enables webhooks configurations" )
42- createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasBranchProtections , "add-branch-protections" , true , "Enables branch protections" )
41+
42+ createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasIssues , "has-issues" , true , "Enables issue pages" )
43+ createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasWiki , "has-wiki" , false , "Enables wiki pages?" )
44+ createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasPages , "has-pages" , false , "Enables github pages?" )
45+ createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasPullApprove , "has-pullapprove" , true , "Enables pull approve" )
46+ createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasTeams , "has-teams" , true , "Enable teams" )
47+ createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasLabels , "has-labels" , true , "Enable labels" )
48+ createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasDefaultLabels , "rm-default-labels" , true , "Removes the default github labels" )
49+ createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasWebhooks , "has-webhooks" , false , "Enables webhooks configurations" )
50+ createRepoCmd .Flags ().BoolVar (& createRepoFlags .HasBranchProtections , "has-branch-protections" , true , "Enables branch protections" )
4351}
4452
4553// RunCreateRepo runs the command to create a new repository
4654func RunCreateRepo (cmd * cobra.Command , args []string ) {
4755 var err error
56+ var org string
4857
4958 name := createRepoFlags .Name
5059 checkEmpty (name , "Please provide a repository name" )
5160
5261 description := createRepoFlags .Description
5362
54- org : = createRepoFlags .Org
63+ org = createRepoFlags .Org
5564 if org == "" {
5665 org = globalConfig .Github .Organization
5766 }
58- checkEmpty (org , "Please provide an organization" )
5967
6068 opts := & repo.GithubRepoOpts {
6169 PullApprove : & repo.PullApproveOpts {
@@ -75,7 +83,15 @@ func RunCreateRepo(cmd *cobra.Command, args []string) {
7583 creator := repo .NewGithub (githubClient )
7684
7785 color .White ("Creating repository..." )
78- err = creator .CreateRepo (name , description , org , createRepoFlags .Private )
86+ ghRepo , err := creator .CreateRepo (org , & github.Repository {
87+ Name : github .String (name ),
88+ Description : github .String (description ),
89+ Private : github .Bool (createRepoFlags .Private ),
90+ HasIssues : github .Bool (createRepoFlags .HasIssues ),
91+ HasWiki : github .Bool (createRepoFlags .HasWiki ),
92+ HasPages : github .Bool (createRepoFlags .HasPages ),
93+ AutoInit : github .Bool (true ),
94+ })
7995 if errors .Cause (err ) == repo .ErrRepositoryAlreadyExists {
8096 color .Cyan ("Repository already exists. Trying to normalize it..." )
8197 } else {
@@ -120,16 +136,19 @@ func RunCreateRepo(cmd *cobra.Command, args []string) {
120136 if errors .Cause (err ) == repo .ErrWebhookAlreadyExist {
121137 color .Cyan ("Webhook already exists, moving on..." )
122138 } else {
123- checkEmpty (errors .Wrap (err , "could add webhooks to repository" ), "" )
139+ checkEmpty (errors .Wrap (err , "could not add webhooks to repository" ), "" )
124140 }
125141 }
126142
127143 if createRepoFlags .HasBranchProtections {
128144 color .White ("Adding branch protections to repository..." )
129145 err = creator .AddBranchProtections (name , org , opts .BranchProtections )
130- checkEmpty (errors .Wrap (err , "could add branch protections to repository" ), "" )
146+ checkEmpty (errors .Wrap (err , "could not add branch protections to repository" ), "" )
131147 }
132148
133- color .Green ("Repository created!" )
134- checkEmpty (err , "Could not create github repo" )
149+ if ghRepo != nil {
150+ color .Green ("Repository created! \n Here is how to access it %s" , * ghRepo .URL )
151+ } else {
152+ color .Green ("Repository normalized!" )
153+ }
135154}
0 commit comments