@@ -111,6 +111,7 @@ func NewGitSourceCreateCommand() *cobra.Command {
111
111
var (
112
112
insCloneOpts * git.CloneOptions
113
113
gsCloneOpts * git.CloneOptions
114
+ createRepo bool
114
115
)
115
116
116
117
cmd := & cobra.Command {
@@ -134,7 +135,7 @@ func NewGitSourceCreateCommand() *cobra.Command {
134
135
if gsCloneOpts .Repo == "" {
135
136
log .G (ctx ).Fatal ("must enter a valid value to --git-src-repo. Example: https://github.com/owner/repo-name/path/to/workflow" )
136
137
}
137
-
138
+
138
139
err := ensureRepo (cmd , args [0 ], insCloneOpts , true )
139
140
if err != nil {
140
141
return err
@@ -153,8 +154,13 @@ func NewGitSourceCreateCommand() *cobra.Command {
153
154
gsCloneOpts .Auth .Password = insCloneOpts .Auth .Password
154
155
}
155
156
157
+ if createRepo {
158
+ gsCloneOpts .CreateIfNotExist = createRepo
159
+ }
160
+
156
161
insCloneOpts .Parse ()
157
162
gsCloneOpts .Parse ()
163
+
158
164
return nil
159
165
},
160
166
RunE : func (cmd * cobra.Command , args []string ) error {
@@ -174,6 +180,8 @@ func NewGitSourceCreateCommand() *cobra.Command {
174
180
},
175
181
}
176
182
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
+
177
185
insCloneOpts = apu .AddCloneFlags (cmd , & apu.CloneFlagsOptions {})
178
186
gsCloneOpts = apu .AddCloneFlags (cmd , & apu.CloneFlagsOptions {
179
187
Prefix : "git-src" ,
@@ -185,6 +193,7 @@ func NewGitSourceCreateCommand() *cobra.Command {
185
193
186
194
func RunGitSourceCreate (ctx context.Context , opts * GitSourceCreateOptions ) error {
187
195
// upsert git-source repo
196
+
188
197
gsRepo , gsFs , err := opts .GsCloneOpts .GetRepo (ctx )
189
198
if err != nil {
190
199
return fmt .Errorf ("failed to clone git-source repo: %w" , err )
@@ -542,7 +551,7 @@ func NewGitSourceEditCommand() *cobra.Command {
542
551
if gsCloneOpts .Repo == "" {
543
552
log .G (ctx ).Fatal ("must enter a valid value to --git-src-repo. Example: https://github.com/owner/repo-name/path/to/workflow" )
544
553
}
545
-
554
+
546
555
err := ensureRepo (cmd , args [0 ], insCloneOpts , true )
547
556
if err != nil {
548
557
return err
0 commit comments