Skip to content

Commit

Permalink
cmd/clone: check project name and honor http flag
Browse files Browse the repository at this point in the history
Since the git passthrough was removed the clone command needs to check
for the project name being passed in the command line and also the
flags instead of pass everything directly to Git.

Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
  • Loading branch information
bmeneg committed Feb 21, 2022
1 parent e6035d5 commit 082de37
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ var cloneCmd = &cobra.Command{
lab clone company/backend-team/awesome-repo`),
PersistentPreRun: labPersistentPreRun,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
log.Fatal("You must specify a repository to clone.")
}

useHTTP, err := cmd.Flags().GetBool("http")
if err != nil {
log.Fatal(err)
}

if useHTTP {
args = append(args, []string{"--http"}...)
}

project, err := gitlab.FindProject(args[0])
if err == gitlab.ErrProjectNotFound {
err = git.New(append([]string{"clone"}, args...)...).Run()
Expand Down

0 comments on commit 082de37

Please sign in to comment.