diff --git a/scripts/svnauth/rebuild_svnauth.php b/scripts/svnauth/rebuild_svnauth.php index ae39295376..9b2c644e58 100755 --- a/scripts/svnauth/rebuild_svnauth.php +++ b/scripts/svnauth/rebuild_svnauth.php @@ -4,6 +4,12 @@ $root = dirname(dirname(dirname(__FILE__))); require_once $root.'/scripts/__init_script__.php'; +function getSVNRepositoryName($repository) { + $uri = $repository->getRemoteURI(); + return preg_replace( + '/https?\:\/\/.*?\/svnroot\/([^\/]+)\/?.*/', '$1', $uri); +} + // Get user's heys and put them to the configuration function handleSingleUserPHID( $viewer, $userPHID, $repository, &$authfile, &$access) { @@ -28,13 +34,15 @@ function handleSingleUserPHID( } } - $uri = $repository->getRemoteURI(); - $repository_name = preg_replace( - '/https?\:\/\/svn.blender.org\/svnroot\/([^\/]+)\/?.*/', '$1', $uri); - if (!array_key_exists($repository_name, $access)) { - $access[$repository_name] = array(); + $repository_name = getSVNRepositoryName($repository); + + // Store write access settings to current subath + $subpath = $repository->getDetail('svn-subpath'); + $repository_pathname = "$repository_name:/$subpath"; + if (!array_key_exists($repository_pathname, $access)) { + $access[$repository_pathname] = array(); } - $access[$repository_name][] = $user_name; + $access[$repository_pathname][] = $user_name; } // Parse repository and put it's members to the config file @@ -47,6 +55,12 @@ function handleSingleRepository( $pushable = $policies[DiffusionCapabilityPush::CAPABILITY]; $type = phid_get_type($pushable->getPHID()); + // Make sure repository is always available for read-only access + $repository_rootpath = getSVNRepositoryName($repository) . ':/'; + if (!array_key_exists($repository_rootpath, $access)) { + $access[$repository_rootpath] = array(); + } + if ($type == PhabricatorProjectPHIDTypeProject::TYPECONST) { $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) @@ -93,12 +107,12 @@ function rebuildConfiguration($what) { } else if ($what == 'ACCESS') { foreach ($access as $repository => $users) { - print("[$repository:/]\n"); + print("[$repository]\n"); foreach ($users as $user) { print("$user = rw\n"); } print("anonsvn = r\n"); - print("* = r\n"); + print("* = r\n\n"); } } return true;