[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emails on branch commits? & disallow commits by branch?

From: Mark D. Baushke
Subject: Re: Emails on branch commits? & disallow commits by branch?
Date: Tue, 07 May 2002 16:01:15 -0700

On Tue, 07 May 2002, Nick Papadonis <address@hidden> wrote
> I know this question has been asked a million times, however I was
> unable to find any examples of commitinfo scripts to do this.

In the contrib directory, you will find a script. Patch
it with the patch found after my .signature. Then create a file in
CVSROOT called locked-tags to contain a list of tags you want to
disallow commits to and the users that are not allowed to commit to
those branches.

It is probably best to revision control the locked-tags file and add
it to the CVSROOT/checkoutlist file so that it is available for your
> Does anyone know how send email when a change has been committed to a
> paticular branch?

That would be via the loginfo trigger. Modify the example
file to read the CVS/Entries file or use a 'cvs -n status' command to
get the information about what branch is being used for the given
commit, then apply it as you wish.

> Is there a way to disallow users to commit changes in certain
> branches?

Yes. Return non-zero return code out of the commitinfo script when the
user is not allowed to commit to that branch.

> I have searched the mailing lists for this one, however can't find
> anything.

        -- Mark

Note: I have not actually tested this patch, but I have used this same
basic concept a number of times in the past. It is meant to show a
possible method, but not the only method of doing what was requested.

--- contrib/     Fri Jan  5 10:18:18 2001
+++ contrib/      Tue May  7 15:54:54 2002
@@ -184,8 +184,34 @@
 open(ENTRIES, $ENTRIES) || die("Cannot open $ENTRIES.\n");
 while (<ENTRIES>) {
-    local($filename, $version) = split('/', substr($_, 1));
+    local($filename, $version,$ts,$opt,$tag) = split('/', substr($_, 1));
     $cvsversion{$filename} = $version;
+    $cvsbranch{$filename} = $tag;
address@hidden = ();
+$login = $ENV{'USER'} || getlogin || (getpwuid($<))[0] || sprintf("uid#%d",$<);
+if (open(CLOSED_BRANCHES, $ENV{'CVSROOT'}.'/CVSROOT/locked-tags')) {
+    while($line = <CLOSED_BRANCHES>) {
+       chop($line);
+       next if ($line =~ /^\#/); # remove comment lines
+       # assume the format is branch user1 user2 user3 ... userN
+       local($branch, @users) = split(' ', $line);
+       push(@locked_tags, $branch) if (grep($login eq $_, @users));
+    }
+    close(CLOSED_BRANCHES);
+# Disallow commits by some users to given branches
+foreach $arg (@files) {
+    if (index($arg, ".") == 0) {
+       next;
+    }
+    if (grep($_ eq $cvsbranch{$arg}, @locked_tags)) {
+       print STDERR "Branch $cvsbranch{$arg} is not allowed for $login\n";
+       exit(1);
+    }
 # Now check each file name passed in, except for dot files.  Dot files

reply via email to

[Prev in Thread] Current Thread [Next in Thread]