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);
Setting labels and assignee on Pull requests failed silently, because
the API endpoint being hit contained '/pulls/' rather than '/issues/'.
"Every pull request is an issue, but not every issue is a pull request.
For this reason, “shared” actions for both features, like manipulating
assignees, labels and milestones, are provided within the Issues API."
https://developer.github.com/v3/pulls/#labels-assignees-and-milestones
If the test assertion fails, we want the pull-request to be closed anyway.
You can't have more than one pull-request merging a given branch into
another, so leaving the PR hanging will cause subsequent test runs to fail
in setup.
Exposes a new API call at GitHub root level to build the complete
set of organisations and teams that current user belongs to.
This change allows to massively reduce the number of calls to GitHub
especially for people that belongs to multiple organisations with
lots of teams and members.
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
The paginated version of listRepositories() was
missing at GHMyself: as side-effect of this bug
when requesting a paginated list of repositories
the ones privately owned by a user were not shown.
This was caused by the missing override of the
listRepositories(final int pageSize) at GHMyself
that caused the GHPerson implementation to invoked.
The GHPerson version uses the /users/:org/repos?per_page=x
URL which *works fine* for organisations but unfortunately
*does not return* private repositories for users.
IMHO GitHub API are quite inconsistent form this
point of view, but they are documented in this way
so that work (inconsistently) as designed.