@@ -111,6 +111,7 @@ func NewGitSourceCreateCommand() *cobra.Command {
111111 var (
112112 insCloneOpts * git.CloneOptions
113113 gsCloneOpts * git.CloneOptions
114+ createRepo bool
114115 )
115116
116117 cmd := & cobra.Command {
@@ -134,7 +135,7 @@ func NewGitSourceCreateCommand() *cobra.Command {
134135 if gsCloneOpts .Repo == "" {
135136 log .G (ctx ).Fatal ("must enter a valid value to --git-src-repo. Example: https://github.com/owner/repo-name/path/to/workflow" )
136137 }
137-
138+
138139 err := ensureRepo (cmd , args [0 ], insCloneOpts , true )
139140 if err != nil {
140141 return err
@@ -153,8 +154,13 @@ func NewGitSourceCreateCommand() *cobra.Command {
153154 gsCloneOpts .Auth .Password = insCloneOpts .Auth .Password
154155 }
155156
157+ if createRepo {
158+ gsCloneOpts .CreateIfNotExist = createRepo
159+ }
160+
156161 insCloneOpts .Parse ()
157162 gsCloneOpts .Parse ()
163+
158164 return nil
159165 },
160166 RunE : func (cmd * cobra.Command , args []string ) error {
@@ -174,6 +180,8 @@ func NewGitSourceCreateCommand() *cobra.Command {
174180 },
175181 }
176182
183+ cmd .Flags ().BoolVar (& createRepo , "create-repo" , false , "If true, will create the specified git-source repo in case it doesn't already exist" )
184+
177185 insCloneOpts = apu .AddCloneFlags (cmd , & apu.CloneFlagsOptions {})
178186 gsCloneOpts = apu .AddCloneFlags (cmd , & apu.CloneFlagsOptions {
179187 Prefix : "git-src" ,
@@ -185,6 +193,7 @@ func NewGitSourceCreateCommand() *cobra.Command {
185193
186194func RunGitSourceCreate (ctx context.Context , opts * GitSourceCreateOptions ) error {
187195 // upsert git-source repo
196+
188197 gsRepo , gsFs , err := opts .GsCloneOpts .GetRepo (ctx )
189198 if err != nil {
190199 return fmt .Errorf ("failed to clone git-source repo: %w" , err )
@@ -542,7 +551,7 @@ func NewGitSourceEditCommand() *cobra.Command {
542551 if gsCloneOpts .Repo == "" {
543552 log .G (ctx ).Fatal ("must enter a valid value to --git-src-repo. Example: https://github.com/owner/repo-name/path/to/workflow" )
544553 }
545-
554+
546555 err := ensureRepo (cmd , args [0 ], insCloneOpts , true )
547556 if err != nil {
548557 return err
0 commit comments