Skip to content

Commit

Permalink
Revert #386 (#393)
Browse files Browse the repository at this point in the history
This reverts commit 149b0c2
("Use PR number from pull_request object").

Reverting [as this seems to have caused an error in some scenarios][1].

[1]: #392
  • Loading branch information
johnboyes authored Sep 6, 2023
1 parent 5a36547 commit f7377ad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions internal/github/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,15 @@ func (a *Action) repositoryName() string {

func (a *Action) pullRequestNumber() int {
event := struct {
PullRequest struct {
Number int `json:"number"`
} `json:"pull_request"`
PullRequestNumber int `json:"number"`
}{}
githubEventJSONFile, err := os.Open(filepath.Clean(os.Getenv("GITHUB_EVENT_PATH")))
panic.IfError(err)
defer githubEventJSONFile.Close() //nolint
byteValue, _ := ioutil.ReadAll(githubEventJSONFile)
panic.IfError(json.Unmarshal(byteValue, &event))

return event.PullRequest.Number
return event.PullRequestNumber
}

func (a *Action) outputResult(result string) {
Expand Down
2 changes: 1 addition & 1 deletion internal/github/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func checkLabels() (int, *bytes.Buffer, *bytes.Buffer) {
}

func setPullRequestNumber(prNumber int) {
githubEventJSON := []byte(fmt.Sprintf(`{ "pull_request": { "number": %d } }`, prNumber))
githubEventJSON := []byte(fmt.Sprintf(`{ "number": %d }`, prNumber))
os.WriteFile(gitHubEventFullPath(), githubEventJSON, os.ModePerm) //nolint
}

Expand Down

0 comments on commit f7377ad

Please sign in to comment.