-1

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?

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
user3574857
  • 377
  • 4
  • 16
  • To create a pull request, you must have changes committed to the your new branch. Go to the repository page on github. And click on "Pull Request" button in the repo header. Pick the branch you wish to have merged using the "Head branch" dropdown. – Sajed Oct 10 '16 at 13:01
  • "From my java application" using the github java Api – user3574857 Oct 10 '16 at 13:06
  • Did you check this sample https://github.com/kevinsawicki/github-api-examples – Sajed Oct 10 '16 at 13:09
  • 1
    SO is not really for asking links, as they rot and tend to have several alternatives, so voting for closure. – eis Oct 10 '16 at 13:12

3 Answers3

2

There are several Java APIs listed in the GitHub developer guide:

https://developer.github.com/libraries/ (search for 'Java')

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
0

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
dir - is your location where this project is present in your local Director
gitDir - is your github repository url
username and password is your github username and password

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.

Arun Patel
  • 29
  • 3
0

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)

Alexander Oh
  • 24,223
  • 14
  • 73
  • 76