Merge branch 'stable-2.16'

* stable-2.16:
  Prevent null pointer when extracting AccountAttribute
  Upgrade bazlets to latest stable-2.15 to build with 2.15.9 API
  Upgrade bazlets to latest stable-2.14 to build with 2.14.18 API
  Do not fetch commit message for ref deletions
  Revert "Fix ref updated event on change deletion"
  Bazel: Include eclipse-out directory in .bazelignore
  Add explanatory comment to empty BUILD file(s)
  Upgrade bazlets to latest stable-2.15 to build with 2.15.7 API
  Upgrade bazlets to latest stable-2.14 to build with 2.14.17 API
  Upgrade bazlets to latest stable-2.15 to build with 2.15.6 API
  WORKSPACE: Make commented out local_path line spaces indent consistent
  Upgrade bazlets to latest stable-2.14 to build with 2.14.16 API
  Migrate `tools/bazel.rc` to `.bazelrc`
  Update build documentation to link to dev-bazel instead of dev-buck
  Align Eclipse compiler settings with core Gerrit's
  Upgrade bazlets to latest stable-2.15 to build with 2.15.5 API
  bazlets: Replace native.git_repository with skylark rule
  Upgrade bazlets to latest stable-2.14 to build with 2.14.15 API
  Add eclipse-out to .gitignore
  Format all build files with buildifier 0.15.0
  Update bazlets to latest revision on stable-2.15
  Remove commented-out code
  Format BUILD files with buildifier 0.12.0
  Format Java files with google-java-format 1.6
  Update bazlets to latest revision on stable-2.14

Change-Id: I56b86f1c63c5f33443486c47a8bfb8039bfd4be0
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractor.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractor.java
index f87f7b5..f1b2c0d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractor.java
@@ -15,6 +15,7 @@
 package com.googlesource.gerrit.plugins.its.base.util;
 
 import com.google.common.collect.ImmutableMap;
+import com.google.gerrit.reviewdb.client.RefNames;
 import com.google.gerrit.server.data.AccountAttribute;
 import com.google.gerrit.server.data.ApprovalAttribute;
 import com.google.gerrit.server.data.ChangeAttribute;
@@ -86,10 +87,14 @@
   }
 
   Map<String, String> extractFrom(RefUpdateAttribute refUpdateAttribute) {
+    String refName = refUpdateAttribute.refName;
+    String refShortName = RefNames.shortName(refName);
     return ImmutableMap.<String, String>builder()
         .put("revision", refUpdateAttribute.newRev)
         .put("revisionOld", refUpdateAttribute.oldRev)
         .put("ref", refUpdateAttribute.refName)
+        .put("refSuffix", refShortName)
+        .put("refPrefix", refName.substring(0, refName.length() - refShortName.length()))
         .build();
   }
 
diff --git a/src/main/resources/Documentation/config-rulebase-common.md b/src/main/resources/Documentation/config-rulebase-common.md
index 17baf77..d232e57 100644
--- a/src/main/resources/Documentation/config-rulebase-common.md
+++ b/src/main/resources/Documentation/config-rulebase-common.md
@@ -425,8 +425,15 @@
 : full name of the project from which a ref was updated.
 
 `ref`
-: git ref that has been updated (Typcially the branch, as for example
-  `master`).
+: git ref that has been updated (Typically the branch, as for example
+  `refs/heads/master`).
+
+`refSuffix`
+: short name of the git ref that has been updated (Typically the branch or the
+tag, as for example `master`).
+
+`refPrefix`
+: prefix of the git ref that has been updated (Example for a branch `refs/heads/`).
 
 `revision`
 : git commit hash the rev is pointing to now.
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractorTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractorTest.java
index 3e61bc1..df88c2f 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractorTest.java
@@ -260,7 +260,7 @@
     RefUpdateAttribute refUpdateAttribute = new RefUpdateAttribute();
     refUpdateAttribute.newRev = "1234567891123456789212345678931234567894";
     refUpdateAttribute.oldRev = "9876543211987654321298765432139876543214";
-    refUpdateAttribute.refName = "testRef";
+    refUpdateAttribute.refName = "refs/heads/master";
 
     replayMocks();
 
@@ -272,7 +272,9 @@
         new ImmutableMap.Builder<String, String>()
             .put("revision", "1234567891123456789212345678931234567894")
             .put("revisionOld", "9876543211987654321298765432139876543214")
-            .put("ref", "testRef")
+            .put("ref", "refs/heads/master")
+            .put("refSuffix", "master")
+            .put("refPrefix", "refs/heads/")
             .build();
     assertEquals("Properties do not match", expected, actual);
   }