summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/GitFilter.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2012-02-03 18:16:16 -0500
committerJames Moger <james.moger@gitblit.com>2012-02-03 18:16:16 -0500
commitb7403152813c7fee783e3c999c7f7ae9fbaacce0 (patch)
treeb30326dec98319aab292b3a160eb9f3e39db104c /src/com/gitblit/GitFilter.java
parentfe7c01a8bd76dff240e74bb770212911e227ba59 (diff)
downloadgitblit-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.java23
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)) {