| | |
| | | import org.eclipse.jgit.transport.ReceiveCommand
|
| | | import org.eclipse.jgit.transport.ReceiveCommand.Result
|
| | | import org.slf4j.Logger
|
| | | import com.gitblit.utils.ClientLogger
|
| | |
|
| | | /**
|
| | | * Sample Gitblit Pre-Receive Hook: blockpush
|
| | |
| | | * chain, "return false" at the appropriate failure points.
|
| | | *
|
| | | * Bound Variables:
|
| | | * gitblit Gitblit Server com.gitblit.GitBlit
|
| | | * repository Gitblit Repository com.gitblit.models.RepositoryModel
|
| | | * user Gitblit User com.gitblit.models.UserModel
|
| | | * commands JGit commands Collection<org.eclipse.jgit.transport.ReceiveCommand>
|
| | | * url Base url for Gitblit String
|
| | | * log Logger instance org.slf4j.Logger
|
| | | * gitblit Gitblit Server com.gitblit.GitBlit
|
| | | * repository Gitblit Repository com.gitblit.models.RepositoryModel
|
| | | * user Gitblit User com.gitblit.models.UserModel
|
| | | * commands JGit commands Collection<org.eclipse.jgit.transport.ReceiveCommand>
|
| | | * url Base url for Gitblit String
|
| | | * logger Logs messages to Gitblit org.slf4j.Logger
|
| | | * clientLogger Logs messages to Git client com.gitblit.utils.ClientLogger
|
| | | *
|
| | | */
|
| | |
|
| | |
| | | */
|
| | | def blocked = false
|
| | | switch (repository.name) {
|
| | | case "ex@mple.git":
|
| | | case 'ex@mple.git':
|
| | | for (ReceiveCommand command : commands) {
|
| | | def updatedRef = command.refName
|
| | | if (updatedRef.equals("refs/heads/master")) {
|
| | | if (updatedRef.equals('refs/heads/master')) {
|
| | | // to reject a command set it's result to anything other than Result.NOT_ATTEMPTED
|
| | | command.setResult(Result.REJECTED_OTHER_REASON, "You are not permitted to write to ${repository.name}:${updatedRef}")
|
| | | blocked = true
|