diff options
author | James Moger <james.moger@gitblit.com> | 2012-02-03 18:16:16 -0500 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2012-02-03 18:16:16 -0500 |
commit | b7403152813c7fee783e3c999c7f7ae9fbaacce0 (patch) | |
tree | b30326dec98319aab292b3a160eb9f3e39db104c /src/com/gitblit/GitFilter.java | |
parent | fe7c01a8bd76dff240e74bb770212911e227ba59 (diff) | |
download | gitblit-b7403152813c7fee783e3c999c7f7ae9fbaacce0.tar.gz gitblit-b7403152813c7fee783e3c999c7f7ae9fbaacce0.zip |
Block pushes to a repository with a working copy (issue 49)
Diffstat (limited to 'src/com/gitblit/GitFilter.java')
-rw-r--r-- | src/com/gitblit/GitFilter.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/com/gitblit/GitFilter.java b/src/com/gitblit/GitFilter.java index a7f0fe74..e76fd767 100644 --- a/src/com/gitblit/GitFilter.java +++ b/src/com/gitblit/GitFilter.java @@ -81,6 +81,25 @@ public class GitFilter extends AccessRestrictionFilter { }
return null;
}
+
+ /**
+ * Determine if the repository can receive pushes.
+ *
+ * @param repository
+ * @param action
+ * @return true if the action may be performed
+ */
+ @Override
+ protected boolean isActionAllowed(RepositoryModel repository, String action) {
+ if (action.equals(gitReceivePack)) {
+ // Push request
+ if (!repository.isBare) {
+ logger.warn("Gitblit does not allow pushes to repositories with a working copy");
+ return false;
+ }
+ }
+ return true;
+ }
/**
* Determine if the repository requires authentication.
@@ -107,8 +126,8 @@ public class GitFilter extends AccessRestrictionFilter { if (!GitBlit.getBoolean(Keys.git.enableGitServlet, true)) {
// Git Servlet disabled
return false;
- }
- boolean readOnly = repository.isFrozen;
+ }
+ boolean readOnly = repository.isFrozen;
if (readOnly || repository.accessRestriction.atLeast(AccessRestrictionType.PUSH)) {
boolean authorizedUser = user.canAccessRepository(repository);
if (action.equals(gitReceivePack)) {
|