Chore: Upgrade Jenkins-job-builder to 6.3.0
[releng/global-jjb.git] / shell / gerrit-branch-lock.sh
index 64d6ec9..88f5a22 100644 (file)
@@ -8,6 +8,7 @@
 # which accompanies this distribution, and is available at
 # http://www.eclipse.org/legal/epl-v10.html
 ##############################################################################
+echo "---> gerrit-branch-lock.sh"
 # Generates a patch to lock|unlock a branch in Gerrit
 #
 # Assumes that the project repository was cloned via ssh and thus uses ssh to
@@ -25,7 +26,7 @@ install_gerrit_hook() {
     ssh_port=$(git remote show origin | grep Fetch | grep 'ssh://' \
         | awk -F'/' '{print $3}' | awk -F':' '{print $2}')
 
-    if [ -z $ssh_url ]; then
+    if [ -z "$ssh_url" ]; then
         echo "ERROR: Gerrit SSH URL not found."
         exit 1
     fi
@@ -38,20 +39,26 @@ install_gerrit_hook
 # Groups must be mapped in the groups file before they can be used
 if ! grep 'Registered Users'; then
     echo -e "global:Registered-Users\tRegistered Users" >> groups
+    git add groups
 fi
 
 mode=$(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep branch | awk '{print $1}')
 case $mode in
     lock)
         echo "Locking branch: $GERRIT_BRANCH"
-        git config -f project.config "access.refs/heads/${GERRIT_BRANCH}.exclusiveGroupPermissions" "submit"
-        git config -f project.config "access.refs/heads/${GERRIT_BRANCH}.submit" "block group Registered Users"
+        git config -f project.config \
+            "access.refs/heads/${GERRIT_BRANCH}.exclusiveGroupPermissions" \
+            "submit"
+        git config -f project.config \
+            "access.refs/heads/${GERRIT_BRANCH}.submit" \
+            "block group Registered Users"
         git commit -asm "Lock branch $GERRIT_BRANCH"
         ;;
 
     unlock)
         echo "Unlocking branch: $GERRIT_BRANCH"
-        git config -f project.config --remove-section "access.refs/heads/${GERRIT_BRANCH}" || true
+        git config -f project.config --remove-section \
+            "access.refs/heads/${GERRIT_BRANCH}" || true
         git commit -asm "Unlock branch $GERRIT_BRANCH"
         ;;