1

In JGit, is it possible to check developer permissions without doing the actions (provided username and password)?

Ex: Is it possible to check if a user can clone a repository without cloning it?

Ex2: Is it possible to check if a user can push to a repository without pushing to it?

Akcore
  • 49
  • 7

1 Answers1

0

Ex1

I think, this is not supported by git itself, so no. (I might be wrong though)

As a workaround, one might use CloneCommand#setNoCheckout(boolean) [1], which prevents downloading any branch (clone command should be pretty quick). The cloned repository (cloned into some temp directory), might be removed immediately, if call succeeded.

Ex2

For push, dry-run can be used. Supported by JGit [2].

Most of the commands have some form of dry-run option.

See: Do all git commands have a dry-run option?

--

[1] https://javadoc.io/doc/org.eclipse.jgit/org.eclipse.jgit/latest/org.eclipse.jgit/org/eclipse/jgit/api/CloneCommand.html

[2] https://javadoc.io/doc/org.eclipse.jgit/org.eclipse.jgit/latest/org.eclipse.jgit/org/eclipse/jgit/api/PushCommand.html

hradecek
  • 2,265
  • 2
  • 20
  • 29