svn: /SVNROOT/ hook-common.inc.php pre-commit

[email protected] (Gwynne Raskind) Sun, 26 Jul 2009 04:00:55 +0000
Newsgroups php.cvs,svn.migration
Message-ID <[email protected]>
--59150dc97fff6c1989dd58ca4bfafd2b79fee99d
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

gwynne                                   Sun, 26 Jul 2009 04:00:55 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=286349

Log:
minor whitespace quirk in debug output fixed. More importantly, the creation of tags/ directories is now allowed subject to location-in-repo restrictions

Changed paths:
    U   SVNROOT/hook-common.inc.php
    U   SVNROOT/pre-commit

Modified: SVNROOT/hook-common.inc.php
===================================================================
--- SVNROOT/hook-common.inc.php	2009-07-26 03:46:22 UTC (rev 286348)
+++ SVNROOT/hook-common.inc.php	2009-07-26 04:00:55 UTC (rev 286349)
@@ -75,7 +75,7 @@
         }
         $final_paths[$actual_path] = $path_actions;
     }
-    debug(print_r($final_paths, 1));
+    debug(trim(print_r($final_paths, 1)));
     return $final_paths;
 }


Modified: SVNROOT/pre-commit
===================================================================
--- SVNROOT/pre-commit	2009-07-26 03:46:22 UTC (rev 286348)
+++ SVNROOT/pre-commit	2009-07-26 04:00:55 UTC (rev 286349)
@@ -35,19 +35,39 @@
         fail("Commits to archived modules are not allowed.\n");
     }

-    //  path contains "/tags/" AND
-    //  path was not added OR
-    //  path was not copied OR
-    //  path is not a directory OR
-    //  path's immediate ancestor is not tags/
-    if (strpos($changed_path, '/tags/') !== FALSE &&
-        (!in_array('added', $path_actions) ||
-        !in_array('copied', $path_actions) ||
-        substr($changed_path, -1) !== '/' ||
-        substr(dirname($changed_path), -5) !== '/tags'))
-    {
-        fail("Committing to a tag is not allowed.\n");
+    //  path contains "/tags/"
+    if (($tags_loc = strpos($changed_path, '/tags/')) !== FALSE) {
+        $allowed_tag = FALSE;
+
+        // path was added AND
+        // path was copied AND
+        // path is a directory AND
+        // path's immediate ancestor is tags/
+        if (in_array('added', $path_actions) &&
+            in_array('copied', $path_actions) &&
+            substr($changed_path, -1) === '/' &&
+            substr(dirname($changed_path), -5) === '/tags')
+        {
+            debug("Tag {$changed_path} passes checks for tag creation.");
+            $allowed_tag = TRUE;
+        }
+        // path was added AND
+        // path does not contain any other structure directories AND
+        // the first occurrence of /tags/ in path is at the end
+        else if (in_array('added', $path_actions) &&
+                 strpos($changed_path, "/branches/") === FALSE &&
+                 strpos($changed_path, "/trunk/") === FALSE &&
+                 $tags_loc === strlen($changed_path) - 6)
+        {
+            debug("Path {$changed_path} passes checks for tags directory creation.");
+            $allowed_tag = TRUE;
+        }
+
+        if (!$allowed_tag) {
+            fail("Committing to a tag is not allowed.\n");
+        }
     }
+
 }

 // -----------------------------------------------------------------------------------------------------------------------------

--59150dc97fff6c1989dd58ca4bfafd2b79fee99d--