I'm trying to create a pull request from my Java application but I can't find any documentation for Github's Java API.
I already implemented all the methods for adding a file, commit, and push.
Any useful links?
I'm trying to create a pull request from my Java application but I can't find any documentation for Github's Java API.
I already implemented all the methods for adding a file, commit, and push.
Any useful links?
There are several Java APIs listed in the GitHub developer guide:
https://developer.github.com/libraries/ (search for 'Java')
I created on Spring boot and HTML project for taking a pull on private GitHub repository to ubuntu server
use this maven dependency
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>5.11.0.202103091610-r</version>
</dependency>
Make Sure the Github project present in your local storage public String pullReq(String dir, String gitDir, String userName, String pass) {
try {
Repository localRepo = new FileRepository(dir + "/.git");
Git git = new Git(localRepo);
CredentialsProvider cp = new UsernamePasswordCredentialsProvider(userName, pass);
git.pull().setCredentialsProvider(cp).call();
git.close();
localRepo.close();
} catch (Exception e) {
return e.getLocalizedMessage();
}
return "success";
}
Github plan to remove UsernamePasswordCredentialsProvider authentication.
I don't know how many days this code is working but currently, it is working.
Github is asking to Use Token Based authentication.
the link of Ruediger is dead:
here is a list of more up to date links:
this would be the api function: https://github-api.kohsuke.org/apidocs/org/kohsuke/github/GHRepository.html#createPullRequest(java.lang.String,java.lang.String,java.lang.String,java.lang.String)