Search code examples
gitgit-push

User push permissions check for a Git repository


I'm making use of jGit for Git related operations. I'm looking for API's there which would let me check if a particular userid has the necessary push permission to that repo. I couldn't find anything related to this. I can see the Repository API class - http://download.eclipse.org/jgit/docs/latest/apidocs/org/eclipse/jgit/lib/Repository.html but that doesn't have anything as well.

One way for this is to actually try to commit/push a new file to the repository and catch exception for the push and check.

But is there any other API which would let me achieve this?

Thanks.


Solution

  • SOLVED: This can be achieved using the egit API's https://github.com/eclipse/egit-github/tree/master/org.eclipse.egit.github.core.

    Basically the API's gives services like the RepositoryService, OrganizationService etc... using which we can see if a user has the necessary permissions.