Skip to content

Commit

Permalink
feat: Allow https cloning
Browse files Browse the repository at this point in the history
  • Loading branch information
NoUseFreak committed Feb 20, 2024
1 parent ad243bc commit 23a9162
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions internal/pkg/command/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
giturls "github.com/whilp/git-urls"
)

var cloneProtocol string

func getCloneCmd() *cobra.Command {
cloneCmd := &cobra.Command{
Use: "clone REPO_URL",
Expand All @@ -29,6 +31,9 @@ func getCloneCmd() *cobra.Command {
fmt.Fprintf(CmdOutput, "cd %s \n", dir)
},
}

cloneCmd.Flags().StringVarP(&cloneProtocol, "clone-protocol", "p", "ssh", "Clone protocol (ssh, https)")

return cloneCmd
}

Expand Down
10 changes: 9 additions & 1 deletion internal/pkg/command/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ The credentials are read from the environment variables:
logrus.Infof("Found %d repos", len(repos))

for _, repo := range repos {
if _, err := cloneRepo(repo.SSHURL); err != nil {
var cloneURL string
if cloneProtocol == "https" {
cloneURL = repo.CloneURL
} else {
cloneURL = repo.SSHURL
}

if _, err := cloneRepo(cloneURL); err != nil {
if err == ErrDirectoryAlreadyExists || errors.Unwrap(err) == ErrDirectoryAlreadyExists {
logrus.Debugf("Skipping existing repo: %s", repo.Name)
} else {
Expand All @@ -86,6 +93,7 @@ The credentials are read from the environment variables:

cmd.Flags().BoolVarP(&cloneForks, "forks", "f", false, "Clone forks")
cmd.Flags().StringVarP(&typeHint, "type-hint", "t", "", "Add a type hint to the URL to force a specific provider")
cmd.Flags().StringVarP(&cloneProtocol, "clone-protocol", "p", "ssh", "Clone protocol (ssh, https)")

return cmd
}

0 comments on commit 23a9162

Please sign in to comment.