Skip to content

Commit

Permalink
Fixed GitHub API rate limit issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Dids committed Jul 19, 2019
1 parent 258790e commit 2f45433
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
15 changes: 11 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ var Hiss bool
// Controls whether to patch buildpkg.sh or not
var patchBuildPkg = true

// TODO: Enable this for public builds once it's done/working
// Controls the experimental hiss command
var hissEnabled = false

// Create a new logger
var log = logrus.New()

Expand Down Expand Up @@ -120,7 +124,7 @@ var rootCmd = &cobra.Command{
}()

// FIXME: Integrate this with the builder?!
if Hiss {
if Hiss && hissEnabled {
game := snake.NewGame()
game.Start()
log.Println("Clobber exiting")
Expand Down Expand Up @@ -525,8 +529,7 @@ func init() {
rootCmd.PersistentFlags().BoolVarP(&InstallerOnly, "installer-only", "i", false, "only build the installer")
rootCmd.PersistentFlags().BoolVarP(&NoClean, "no-clean", "n", false, "skip cleaning of dirty files")

// TODO: Enable this for public builds once it's done/working
if Version == "0.0.0" {
if hissEnabled {
rootCmd.PersistentFlags().BoolVarP(&Hiss, "hiss", "", false, "that's Sir Hiss to you")
}
}
Expand Down Expand Up @@ -609,7 +612,11 @@ func runCommand(command string) {
}

func getGitHubReleaseLink(url string, filter string) string {
cmd := "curl -s " + url + " | grep \"" + filter + "\" | cut -d : -f 2,3 | tr -d \\\""
cmd := "curl"
if len(os.Getenv("GITHUB_API_TOKEN")) > 0 {
cmd += " -H \"Authorization: token " + os.Getenv("GITHUB_API_TOKEN") + "\""
}
cmd += " -s " + url + " | grep \"" + filter + "\" | cut -d : -f 2,3 | tr -d \\\""
out, err := exec.Command("bash", "-c", cmd).Output()
if err != nil {
return fmt.Sprintf("Failed to execute command: %s", cmd)
Expand Down
6 changes: 5 additions & 1 deletion util/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ func DownloadFile(url string, path string) error {
return err
}
defer out.Close()
resp, err := http.Get(url)
req, err := http.NewRequest("GET", url, nil)
// if len(os.Getenv("GITHUB_API_TOKEN")) > 0 {
// req.Header.Set("Authorization", "token "+string(os.Getenv("GITHUB_API_TOKEN")))
// }
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
Expand Down

0 comments on commit 2f45433

Please sign in to comment.