Skip to content

Commit

Permalink
Check directory before making API request
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Nov 23, 2021
1 parent 2d60090 commit 0da65f0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/fetcher.go
Expand Up @@ -28,14 +28,6 @@ func FetchRepo(args *AppArgs) error {
// parse the repo to two parts
repo, version := ParseRepo(args.repo)

if version == "" {
defaultBranch, err := getDefaultBranchFromGitHubApi(repo)
if err != nil {
return err
}
version = *defaultBranch
}

if !args.force {
exists, err := pathExists(args.destination)
if err != nil {
Expand All @@ -49,6 +41,14 @@ func FetchRepo(args *AppArgs) error {

}

if version == "" {
defaultBranch, err := getDefaultBranchFromGitHubApi(repo)
if err != nil {
return err
}
version = *defaultBranch
}

// Get GitHub repo archive URL from repo and branch
url := fmt.Sprintf("https://codeload.github.com/%s/tar.gz/refs/heads/%s", repo, version)
fmt.Println("Downloading from", url)
Expand Down

0 comments on commit 0da65f0

Please sign in to comment.