Skip to content

Commit

Permalink
fix: pagination ignored 1, treat ssh setup while clonning
Browse files Browse the repository at this point in the history
  • Loading branch information
Excoriate committed Sep 22, 2022
1 parent 8b3eb0e commit cbed9e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions app/cli/actions/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,22 @@ func clone(s services.IGitHubSvc, repoDir string, repoName string, gitURL string

isCloned, err := s.CloneRepository(gitURL, repoDir)

// TODO: Smartly, handle errors and retry if there's an SSH(
// sh) way of connecting rather than pure HTTP.
if !isCloned && err != nil {
// Replace URL with the SSH format
gitURL = strings.Replace(gitURL, "https://", "git@", 1)
gitURL = strings.Replace(gitURL, ".com/", ".com:", 1)
gitURL = strings.Replace(gitURL, ".com:", ".com:", 1)
gitURL = strings.Replace(gitURL, ".git/", ".git:", 1)
gitURL = strings.Replace(gitURL, ".git:", ".git:", 1)
gitURL = strings.Replace(gitURL, ".git", ".git", 1)
gitURL = strings.Replace(gitURL, ".git/", ".git/", 1)
gitURL = strings.Replace(gitURL, ".git", ".git", 1)

isCloned, err = s.CloneRepository(gitURL, repoDir)
}

if err != nil {
if err != nil {
ux.OutError(fmt.Sprintf("The repository %s could not be cloned due to an error. "+
Expand Down
2 changes: 1 addition & 1 deletion app/cli/pkg/clients/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Auth struct {

func (g Client) GetURL(org string, page int) string {
var uri string
if page > 1 {
if page != 0 {
uri = fmt.Sprintf("%s/orgs/%s/%s?type=all&per_page=100&page=%d", base, org, api, page)
} else {
uri = fmt.Sprintf("%s/orgs/%s/%s?type=all&per_page=100", base, org, api)
Expand Down

0 comments on commit cbed9e6

Please sign in to comment.