-
Notifications
You must be signed in to change notification settings - Fork 769
Closed
Description
Given this groovy snippet:
#!/usr/bin/env groovy
import org.kohsuke.github.*
@GrabResolver(name = 'jenkins-api', root = 'http://central.maven.org/maven2')
@Grab("org.kohsuke:github-api:1.95")
String repo = "<repo>"
String apiToken = "<token>"
String organization = "<org>"
int prId = <id>
def getRepository = { repoName ->
GitHub github = GitHub.connectUsingOAuth(apiToken)
return github.getRepository("${organization}/${repoName}")
}
def getPullRequestChanges = { repoName, id ->
GHPullRequest pullRequest = getRepository(repoName).getPullRequest(id)
return pullRequest.listFiles().collect()
}
List<GHPullRequestFileDetail> changes = getPullRequestChanges(repo, prId)
changes.each {
println "Commit: https://github.com/${organization}/${repo}/commit/${it.sha}"
}
I'm expecting to get the SHA where the file was changed on the branch but that doesn't seem to be the case. I can see the 6 files changed on the PR but when I navigate to any of their associated SHAs, I get a 404.