Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

repo-specific umask

manually smoke tested but should be fine
  • Loading branch information...
commit a454111d32753a60cc909b88fe7738eeed41f532 1 parent 858f13c
@sitaramc authored
Showing with 54 additions and 0 deletions.
  1. +54 −0 src/lib/Gitolite/Triggers/RepoUmask.pm
View
54 src/lib/Gitolite/Triggers/RepoUmask.pm
@@ -0,0 +1,54 @@
+package Gitolite::Triggers::RepoUmask;
+
+use Gitolite::Rc;
+use Gitolite::Common;
+use Gitolite::Conf::Load;
+
+use strict;
+use warnings;
+
+# setting a repo specific umask
+# ----------------------------------------------------------------------
+
+=for usage
+
+ * In the rc file, add 'RepoUmask::pre_git' and 'RepoUmask::post_create' to
+ the corresponding trigger lists.
+
+ * For each repo that is to get a different umask than the default, add a
+ line like this:
+
+ option umask = 0027
+
+=cut
+
+# sadly option/config values are not available at pre_create time for normal
+# repos. So we have to do a one-time fixup in a post_create trigger.
+sub post_create {
+ my $repo = $_[1];
+
+ my $umask = option($repo, 'umask');
+ _chdir($rc{GL_REPO_BASE}); # because using option() moves us to ADMIN_BASE!
+
+ return unless $umask;
+
+ # unlike the one in the rc file, this is a string
+ $umask = oct($umask);
+ my $mode = "0" . sprintf("%o", $umask ^ 0777);
+
+ system("chmod -R $mode $repo.git >&2");
+}
+
+sub pre_git {
+ my $repo = $_[1];
+
+ my $umask = option($repo, 'umask');
+ _chdir($rc{GL_REPO_BASE}); # because using option() moves us to ADMIN_BASE!
+
+ return unless $umask;
+
+ # unlike the one in the rc file, this is a string
+ umask oct($umask);
+}
+
+1;
Please sign in to comment.
Something went wrong with that request. Please try again.