Skip to content

Commit

Permalink
Remove accept header; change goarch for darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDuffy committed Oct 5, 2020
1 parent af01bd4 commit 8d32441
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ clean:
.PHONY: build
build: clean build-darwin build-linux

build-%:
GOOS=$* GOARCH=386 go build -ldflags '${LDFLAGS}' -o ${PREFIX}${NAME}-$*
build-linux:
GOOS=linux GOARCH=386 go build -ldflags '${LDFLAGS}' -o ${PREFIX}${NAME}-linux

build-darwin:
GOOS=darwin GOARCH=amd64 go build -ldflags '${LDFLAGS}' -o ${PREFIX}${NAME}-darwin

.PHONY: docker
docker:
Expand Down
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (ex *Executor) makeRequest(method string, url string) (res *http.Response,
if err != nil {
return nil, err
}
req.Header.Add("Accept", "application/vnd.github.v3+json")

req.Header.Add("Authorization", "token "+ex.token)
res, _ = ex.client.Do(req)
if res.StatusCode >= 400 {
Expand All @@ -93,7 +93,7 @@ func (ex *Executor) listClosedPullRequests(user string, repo string, days int) (
res, err := ex.makeRequest("GET", "repos/"+user+"/"+repo+"/pulls?state=closed&sort=updated&direction=desc&per_page=100&page="+strconv.Itoa(page))

if err != nil {
return pullRequests, errors.New("failed to get pull requests (" + err.Error() + ")")
return pullRequests, errors.New("failed to get closed pull requests (" + err.Error() + ")")
}

d := json.NewDecoder(res.Body)
Expand All @@ -103,7 +103,7 @@ func (ex *Executor) listClosedPullRequests(user string, repo string, days int) (
err = d.Decode(&prs.PullRequests)

if err != nil {
return pullRequests, errors.New("failed to parse pull requests (" + err.Error() + ")")
return pullRequests, errors.New("failed to parse closed pull requests (" + err.Error() + ")")
}

for _, pr := range prs.PullRequests {
Expand All @@ -130,7 +130,7 @@ func (ex *Executor) listOpenPullRequests(user string, repo string) ([]pullReques
res, err := ex.makeRequest("GET", "repos/"+user+"/"+repo+"/pulls?state=open&sort=updated&direction=desc&per_page=100&page="+strconv.Itoa(page))

if err != nil {
return pullRequests, errors.New("failed to get pull requests (" + err.Error() + ")")
return pullRequests, errors.New("failed to get open pull requests (" + err.Error() + ")")
}

d := json.NewDecoder(res.Body)
Expand All @@ -140,7 +140,7 @@ func (ex *Executor) listOpenPullRequests(user string, repo string) ([]pullReques
err = d.Decode(&prs.PullRequests)

if err != nil {
return pullRequests, errors.New("failed to parse pull requests (" + err.Error() + ")")
return pullRequests, errors.New("failed to parse open pull requests (" + err.Error() + ")")
}

pullRequests = append(pullRequests, prs.PullRequests...)
Expand Down

0 comments on commit 8d32441

Please sign in to comment.