With the previous change if no credentials were defined Github.connect() would
fall back on an anonymous connection.
This commit changes the behaviour back to what it was before so that if there
are no credentials defined in the ~/.github file and no credentials defined
in the environment an IOException is thrown to alert the method caller.
The caller can call Github.connectAnonymously() if that scenario is allowed.
This should handle most cases unless callers are depending on the
FileNotFoundException being specifically thrown instead of an IOException.
There is a file field inside of GHCompare but no getter to extract the values
for analysis.
There are contents in that field so I've added a new get method so that they
can be extracted.
Using the Jenkins EnvInject or Credentials Binding Plugins its possible to
pass credentials as Environment Variables.
Its useful for Github.connect() to be able to directly read the values of the
'login', 'password' and 'oauth' properties directly from the environment.
This commit modifies the base Github.connect() method to resolve credentials
in two steps:
1. ~/.github credentials file if it exists.
2. login, password or oauth variables from the environment
A further fromEnvironment() method is provided to support
loading from non-standard variable names.
The old Github.connect() method would throw an IOException if the ~/.github file
did not exist. Now it will fail silently instead dropping back to the anonymous
users access level.
Added new unit tests into GitHubTest.
The wrong .wrap method was used for pull requests initialized by state
(GHRepository.getPullReqests).
The wrong wrap call was introduced in 9fd34aec7f
This commit sets it back to the .wrapUp method which makes sure the pull request
substructure has the repo object set properly.
Without this change a NullPointerException is thrown on the last line of this
code because the repo object inside of the remoteRepository object is null:
GHRepository repo = github.getRepository(targetRepository);
List<GHPullRequest> openPullRequests = repo.getPullRequests(GHIssueState.OPEN);
for (GHPullRequest pullRequest : openPullRequests) {
GHCommitPointer head = pullRequest.getHead();
GHRepository remoteRepository = head.getRepository();
String commitId = head.getSha();
GHCommit headCommit = remoteRepository.getCommit(commitId);