2

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
  • 119
  • 1
  • 1
  • 10

1 Answers1

1

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,455
  • 2
  • 21
  • 30
  • A --dry-run doesn't send the commands the client would use from client to server, therefore permissions will not be checked server side. – b0gusb Aug 31 '23 at 08:17