Skip to content

Commit

Permalink
remove a few consts
Browse files Browse the repository at this point in the history
  • Loading branch information
chicoxyzzy committed Jun 22, 2024
1 parent 50d6631 commit 9a0ce09
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions cli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ import (
)

const (
githubTarballURL = "https://github.com/%s/%s/tarball/%s"
githubAPIURL = "https://api.github.com/repos/%s/%s/branches/%s"
owner = "dispatchrun"
githubTarballURL = "https://github.com/dispatchrun/%s/tarball/main"
githubAPIURL = "https://api.github.com/repos/dispatchrun/%s/branches/main"
repo = "dispatch-examples"
branch = "main"
dispatchUserDir = "dispatch"
)

Expand Down Expand Up @@ -62,7 +60,7 @@ func isDirectoryEmpty(path string) (bool, error) {
}

func downloadAndExtractTemplates(destDir string) error {
url := fmt.Sprintf(githubTarballURL, owner, repo, branch)
url := fmt.Sprintf(githubTarballURL, repo)
resp, err := http.Get(url)
if err != nil {
return err
Expand Down Expand Up @@ -168,8 +166,8 @@ func getAppDataDir(appName string) (string, error) {
return appDataDir, nil
}

func getLatestCommitSHA(owner, repo, branch string) (string, error) {
url := fmt.Sprintf(githubAPIURL, owner, repo, branch)
func getLatestCommitSHA(repo string) (string, error) {
url := fmt.Sprintf(githubAPIURL, repo)
resp, err := http.Get(url)
if err != nil {
return "", err
Expand Down Expand Up @@ -312,7 +310,7 @@ func initCommand() *cobra.Command {
}
}

remoteSHA, err := getLatestCommitSHA(owner, repo, branch)
remoteSHA, err := getLatestCommitSHA(repo)
if err != nil {
cmd.Printf("failed to get latest commit SHA: %v", err)
}
Expand Down

0 comments on commit 9a0ce09

Please sign in to comment.