Merge branch 'stable-2.12' into stable-2.13

* stable-2.12:
  Show more fields in ls-users command
  Add options to filter by active flag in ls-users command
  Escape double dashes in documentation

Change-Id: I5f1177f6dbc0fe99ce702963eccd588fb008470a
diff --git a/lib/gerrit/BUCK b/lib/gerrit/BUCK
index 53cc550..f1b581e 100644
--- a/lib/gerrit/BUCK
+++ b/lib/gerrit/BUCK
@@ -1,12 +1,12 @@
 include_defs('//bucklets/maven_jar.bucklet')
 
-VER = '2.12.4'
+VER = '2.13'
 REPO = MAVEN_CENTRAL
 
 maven_jar(
   name = 'plugin-api',
   id = 'com.google.gerrit:gerrit-plugin-api:' + VER,
-  sha1 = 'aad189fe4f9fa5c3f8048b5e4972512b4b3e2a24',
+  sha1 = 'e25d55b8f41627c4ae6b9d2069ec398638b219a3',
   attach_source = False,
   repository = REPO,
   license = 'Apache2.0',
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 4469749..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (C) 2012 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>com.googlesource.gerrit.plugins</groupId>
-  <artifactId>admin-console</artifactId>
-  <packaging>jar</packaging>
-  <version>2.12</version>
-  <properties>
-    <Gerrit-ApiType>plugin</Gerrit-ApiType>
-    <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
-  </properties>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jar-plugin</artifactId>
-        <version>2.4</version>
-        <configuration>
-          <archive>
-            <manifestEntries>
-              <Gerrit-SshModule>com.googlesource.gerrit.plugins.adminconsole.AdminConsoleCommandModule</Gerrit-SshModule>
-
-              <Implementation-Vendor>Gerrit Code Review</Implementation-Vendor>
-              <Implementation-URL>https://gerrit-review.googlesource.com/#/admin/projects/plugins/admin-console</Implementation-URL>
-
-              <Implementation-Title>Plugin ${project.artifactId}</Implementation-Title>
-              <Implementation-Version>${project.version}</Implementation-Version>
-
-              <Gerrit-ApiType>${Gerrit-ApiType}</Gerrit-ApiType>
-              <Gerrit-ApiVersion>${Gerrit-ApiVersion}</Gerrit-ApiVersion>
-              <Gerrit-PluginName>admin-console</Gerrit-PluginName>
-            </manifestEntries>
-          </archive>
-        </configuration>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>2.3.2</version>
-        <configuration>
-          <source>1.6</source>
-          <target>1.6</target>
-          <encoding>UTF-8</encoding>
-        </configuration>
-      </plugin>
-    </plugins>
-
-  </build>
-
-  <dependencies>
-    <dependency>
-      <groupId>com.google.gerrit</groupId>
-      <artifactId>gerrit-${Gerrit-ApiType}-api</artifactId>
-      <version>${Gerrit-ApiVersion}</version>
-      <scope>provided</scope>
-    </dependency>
-  </dependencies>
-
-  <repositories>
-    <repository>
-      <id>gerrit-api-repository</id>
-      <url>https://gerrit-api.commondatastorage.googleapis.com/snapshot/</url>
-    </repository>
-   </repositories>
-</project>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/AdminConsoleCommandModule.java b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/AdminConsoleCommandModule.java
index fece7cb..98da362 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/AdminConsoleCommandModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/AdminConsoleCommandModule.java
@@ -21,8 +21,8 @@
   protected void configureCommands() {
     command(ShowAccountCommand.class);
     command(ListUsersCommand.class);
-   alias("show-account", ShowAccountCommand.class);
-   alias("show-repo-account-access", ShowRepoAccountAccessCommand.class);
-   alias("show-repo-access", ShowRepoAccessCommand.class);
+    alias("show-account", ShowAccountCommand.class);
+    alias("show-repo-account-access", ShowRepoAccountAccessCommand.class);
+    alias("show-repo-access", ShowRepoAccessCommand.class);
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ListUsersCommand.java b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ListUsersCommand.java
index f304b0d..8ead5ad 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ListUsersCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ListUsersCommand.java
@@ -84,7 +84,7 @@
 
   private String getUsername(Account account) throws OrmException {
     String id = account.getId().toString();
-    Account accountFromResolver = accountResolver.find(id);
+    Account accountFromResolver = accountResolver.find(db, id);
     return accountFromResolver == null ? null
         : accountFromResolver.getUserName();
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowAccountCommand.java b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowAccountCommand.java
index b7756ee..5c439ff 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowAccountCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowAccountCommand.java
@@ -14,29 +14,21 @@
 
 package com.googlesource.gerrit.plugins.adminconsole;
 
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jgit.errors.ConfigInvalidException;
-import org.kohsuke.args4j.Argument;
-import org.kohsuke.args4j.Option;
-
 import com.google.gerrit.common.data.GlobalCapability;
 import com.google.gerrit.extensions.annotations.CapabilityScope;
 import com.google.gerrit.extensions.annotations.RequiresCapability;
 import com.google.gerrit.extensions.common.GroupInfo;
+import com.google.gerrit.extensions.common.SshKeyInfo;
+import com.google.gerrit.extensions.restapi.AuthException;
 import com.google.gerrit.reviewdb.client.Account;
 import com.google.gerrit.reviewdb.client.Account.Id;
 import com.google.gerrit.reviewdb.client.AccountExternalId;
-import com.google.gerrit.reviewdb.client.AccountSshKey;
 import com.google.gerrit.reviewdb.server.ReviewDb;
 import com.google.gerrit.server.IdentifiedUser;
 import com.google.gerrit.server.account.AccountResolver;
 import com.google.gerrit.server.account.AccountResource;
 import com.google.gerrit.server.account.GetGroups;
+import com.google.gerrit.server.account.GetSshKeys;
 import com.google.gerrit.sshd.CommandMetaData;
 import com.google.gerrit.sshd.SshCommand;
 import com.google.gwtorm.server.OrmException;
@@ -44,6 +36,16 @@
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 
+import org.eclipse.jgit.errors.ConfigInvalidException;
+import org.kohsuke.args4j.Argument;
+import org.kohsuke.args4j.Option;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Set;
+
 @RequiresCapability(value=GlobalCapability.ADMINISTRATE_SERVER, scope=CapabilityScope.CORE)
 @CommandMetaData(name = "show-account", description = "Displays user information")
 public final class ShowAccountCommand extends SshCommand {
@@ -60,21 +62,23 @@
   @Option(name = "--show-keys", usage = "show user's public keys?")
   private boolean showKeys = false;
 
-  final AccountResolver accountResolver;
+  private final AccountResolver accountResolver;
   private final SchemaFactory<ReviewDb> schema;
   private final Provider<GetGroups> accountGetGroups;
   private final IdentifiedUser.GenericFactory userFactory;
+  private final Provider<GetSshKeys> getSshKeys;
 
   @Inject
-  ShowAccountCommand(AccountResolver ar,
-      final Provider<GetGroups> accountGetGroups,
-      final IdentifiedUser.GenericFactory userFactory,
-      SchemaFactory<ReviewDb> schema) throws ConfigInvalidException,
-      IOException {
-    accountResolver = ar;
+  ShowAccountCommand(AccountResolver accountResolver,
+      Provider<GetGroups> accountGetGroups,
+      IdentifiedUser.GenericFactory userFactory,
+      Provider<GetSshKeys> getSshKeys,
+      SchemaFactory<ReviewDb> schema) {
+    this.accountResolver = accountResolver;
     this.accountGetGroups = accountGetGroups;
     this.userFactory = userFactory;
     this.schema = schema;
+    this.getSshKeys = getSshKeys;
   }
 
   @Override
@@ -86,35 +90,32 @@
           "You need to tell me who to find:  LastName,\\\\ Firstname, email@address.com, account id or an user name.  "
               + "Be sure to double-escape spaces, for example: \"show-account Last,\\\\ First\"");
     }
-
-    Set<Id> idList = accountResolver.findAll(name);
-    if (idList.isEmpty()) {
-      throw new UnloggedFailure(1,
-          "No accounts found for your query: \""
-              + name
-              + "\""
-              + " Tip: Try double-escaping spaces, for example: \"show-account Last,\\\\ First\"");
-    } else {
+    try (ReviewDb db = schema.open()) {
+      Set<Id> idList = accountResolver.findAll(db, name);
+      if (idList.isEmpty()) {
+        throw new UnloggedFailure(1,
+            "No accounts found for your query: \""
+                + name
+                + "\""
+                + " Tip: Try double-escaping spaces, for example: \"show-account Last,\\\\ First\"");
+      }
       stdout.println("Found " + idList.size() + " result"
           + (idList.size() > 1 ? "s" : "") + ": for query: \"" + name + "\"");
       stdout.println();
-    }
 
-    for (Id id : idList) {
-      account = accountResolver.find(id.toString());
-      if (account == null) {
-        throw new UnloggedFailure("Account " + id.toString() + " does not exist.");
-      }
-      stdout.println("Full name:         " + account.getFullName());
-      stdout.println("Account Id:        " + id.toString());
-      stdout.println("Preferred Email:   " + account.getPreferredEmail());
-      stdout.println("User Name:         " + account.getUserName());
-      stdout.println("Active:            " + account.isActive());
-      stdout.println("Registered on:     " + account.getRegisteredOn());
+      for (Id id : idList) {
+        account = accountResolver.find(db, id.toString());
+        if (account == null) {
+          throw new UnloggedFailure("Account " + id.toString() + " does not exist.");
+        }
+        stdout.println("Full name:         " + account.getFullName());
+        stdout.println("Account Id:        " + id.toString());
+        stdout.println("Preferred Email:   " + account.getPreferredEmail());
+        stdout.println("User Name:         " + account.getUserName());
+        stdout.println("Active:            " + account.isActive());
+        stdout.println("Registered on:     " + account.getRegisteredOn());
 
-      final ReviewDb db = schema.open();
 
-      try {
         stdout.println("");
         stdout.println("External Ids:");
         stdout.println(String
@@ -130,40 +131,43 @@
         if (showKeys) {
           stdout.println("");
           stdout.println("Public Keys:");
-          List<AccountSshKey> sshKeys =
-              db.accountSshKeys().byAccount(account.getId()).toList();
+          List<SshKeyInfo> sshKeys;
+          try {
+            sshKeys = getSshKeys.get()
+                .apply(new AccountResource(userFactory.create(id)));
+          } catch (AuthException | IOException | ConfigInvalidException e) {
+            throw new UnloggedFailure(1, "Error getting sshkeys: " + e.getMessage(), e);
+          }
           if (sshKeys == null || sshKeys.isEmpty()) {
             stdout.println("None");
           } else {
             stdout.println(String.format("%-9s %s", "Status:", "Key:"));
-            for (AccountSshKey sshKey : sshKeys) {
-              stdout.println(String.format("%-9s %s", (sshKey.isValid()
-                  ? "Active" : "Inactive"), sshKey.getSshPublicKey()));
+            for (SshKeyInfo sshKey : sshKeys) {
+              stdout.println(String.format("%-9s %s", (sshKey.valid
+                  ? "Active" : "Inactive"), sshKey.sshPublicKey));
             }
           }
         }
-      } finally {
-        db.close();
-      }
 
-      if (showGroups) {
-        stdout.println();
-        stdout.println("Member of groups"
-            + (filterGroups == null ? "" : " (Filtering on \"" + filterGroups
-                + "\")") + ":");
-        List<GroupInfo> groupInfos =
-            accountGetGroups.get().apply(
-                new AccountResource(userFactory.create(id)));
+        if (showGroups) {
+          stdout.println();
+          stdout.println("Member of groups"
+              + (filterGroups == null ? "" : " (Filtering on \"" + filterGroups
+                  + "\")") + ":");
+          List<GroupInfo> groupInfos =
+              accountGetGroups.get().apply(
+                  new AccountResource(userFactory.create(id)));
 
-        Collections.sort(groupInfos, new CustomComparator());
-        for (GroupInfo groupInfo : groupInfos) {
-          if (null == filterGroups || groupInfo.name.toLowerCase().contains(filterGroups.toLowerCase
-              ())) {
-            stdout.println(groupInfo.name);
+          Collections.sort(groupInfos, new CustomComparator());
+          for (GroupInfo groupInfo : groupInfos) {
+            if (null == filterGroups || groupInfo.name.toLowerCase().contains(filterGroups.toLowerCase
+                ())) {
+              stdout.println(groupInfo.name);
+            }
           }
         }
+        stdout.println("");
       }
-      stdout.println("");
     }
   }
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccessCommand.java b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccessCommand.java
index d8ca185..1252b23 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccessCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccessCommand.java
@@ -14,13 +14,6 @@
 
 package com.googlesource.gerrit.plugins.adminconsole;
 
-import java.io.IOException;
-
-import org.eclipse.jgit.errors.ConfigInvalidException;
-import org.eclipse.jgit.errors.RepositoryNotFoundException;
-import org.kohsuke.args4j.Argument;
-import org.kohsuke.args4j.Option;
-
 import com.google.gerrit.common.data.AccessSection;
 import com.google.gerrit.common.data.GlobalCapability;
 import com.google.gerrit.common.data.Permission;
@@ -34,6 +27,13 @@
 import com.google.gerrit.sshd.SshCommand;
 import com.google.inject.Inject;
 
+import org.eclipse.jgit.errors.ConfigInvalidException;
+import org.eclipse.jgit.errors.RepositoryNotFoundException;
+import org.kohsuke.args4j.Argument;
+import org.kohsuke.args4j.Option;
+
+import java.io.IOException;
+
 @RequiresCapability(value=GlobalCapability.ADMINISTRATE_SERVER, scope=CapabilityScope.CORE)
 @CommandMetaData(name = "show-repo-access", description = "Displays access on a specific repository")
 public final class ShowRepoAccessCommand extends SshCommand {
@@ -45,8 +45,7 @@
   private boolean wide;
 
   @Inject
-  ShowRepoAccessCommand(final MetaDataUpdate.Server metaDataUpdateFactory)
-      throws ConfigInvalidException, IOException {
+  ShowRepoAccessCommand(MetaDataUpdate.Server metaDataUpdateFactory) {
     this.metaDataUpdateFactory = metaDataUpdateFactory;
   }
 
@@ -66,7 +65,7 @@
     if (projectName.isEmpty()) {
       throw new UnloggedFailure(1, "Please specify a project to show access for");
     }
-    final Project.NameKey nameKey = new Project.NameKey(projectName);
+    Project.NameKey nameKey = new Project.NameKey(projectName);
 
     permissionGroupWidth = wide ? Integer.MAX_VALUE : columns - 9 - 5 - 9;
 
@@ -97,11 +96,10 @@
     }
   }
 
-  private String format(final String s) {
+  private String format(String s) {
     if (s.length() < permissionGroupWidth) {
       return s;
-    } else {
-      return s.substring(0, permissionGroupWidth);
     }
+    return s.substring(0, permissionGroupWidth);
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccountAccessCommand.java b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccountAccessCommand.java
index e1623bb..e80f81b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccountAccessCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccountAccessCommand.java
@@ -14,16 +14,6 @@
 
 package com.googlesource.gerrit.plugins.adminconsole;
 
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jgit.errors.ConfigInvalidException;
-import org.eclipse.jgit.errors.RepositoryNotFoundException;
-import org.kohsuke.args4j.Argument;
-import org.kohsuke.args4j.Option;
-
 import com.google.gerrit.common.data.AccessSection;
 import com.google.gerrit.common.data.GlobalCapability;
 import com.google.gerrit.common.data.Permission;
@@ -33,6 +23,7 @@
 import com.google.gerrit.extensions.common.GroupInfo;
 import com.google.gerrit.reviewdb.client.Account;
 import com.google.gerrit.reviewdb.client.Account.Id;
+import com.google.gerrit.reviewdb.server.ReviewDb;
 import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.IdentifiedUser;
 import com.google.gerrit.server.account.AccountResolver;
@@ -42,9 +33,18 @@
 import com.google.gerrit.server.git.ProjectConfig;
 import com.google.gerrit.sshd.CommandMetaData;
 import com.google.gerrit.sshd.SshCommand;
+import com.google.gwtorm.server.SchemaFactory;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 
+import org.eclipse.jgit.errors.RepositoryNotFoundException;
+import org.kohsuke.args4j.Argument;
+import org.kohsuke.args4j.Option;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 @RequiresCapability(value=GlobalCapability.ADMINISTRATE_SERVER, scope=CapabilityScope.CORE)
 @CommandMetaData(name = "show-repo-account-access", description = "Displays user's access on a specific repository")
 public final class ShowRepoAccountAccessCommand extends SshCommand {
@@ -61,21 +61,23 @@
 
   @Inject
   ShowRepoAccountAccessCommand(
-      final MetaDataUpdate.Server metaDataUpdateFactory,
-      final Provider<GetGroups> accountGetGroups,
+      MetaDataUpdate.Server metaDataUpdateFactory,
+      Provider<GetGroups> accountGetGroups,
       AccountResolver accountResolver,
-      final IdentifiedUser.GenericFactory userFactory)
-      throws ConfigInvalidException, IOException {
+      IdentifiedUser.GenericFactory userFactory,
+      SchemaFactory<ReviewDb> schema) {
     this.metaDataUpdateFactory = metaDataUpdateFactory;
     this.accountGetGroups = accountGetGroups;
     this.accountResolver = accountResolver;
     this.userFactory = userFactory;
+    this.schema = schema;
   }
 
   private final MetaDataUpdate.Server metaDataUpdateFactory;
   private final AccountResolver accountResolver;
   private final Provider<GetGroups> accountGetGroups;
   private final IdentifiedUser.GenericFactory userFactory;
+  private final SchemaFactory<ReviewDb> schema;
   private int columns = 80;
   private int permissionGroupWidth;
 
@@ -98,88 +100,88 @@
           "You need to tell me who to find:  LastName,\\\\ Firstname, email@address.com, account id or an user name.  "
               + "Be sure to double-escape spaces, for example: \"show-repo-account-access All-Projects --user Last,\\\\ First\"");
     }
+    try (ReviewDb db = schema.open()) {
+      Set<Id> idList = accountResolver.findAll(db, name);
+      if (idList.isEmpty()) {
+        throw new UnloggedFailure(1,
+            "No accounts found for your query: \""
+                + name
+                + "\""
+                + " Tip: Try double-escaping spaces, for example: \"--user Last,\\\\ First\"");
+      }
 
-    Set<Id> idList = accountResolver.findAll(name);
-    if (idList.isEmpty()) {
-      throw new UnloggedFailure(1,
-          "No accounts found for your query: \""
-              + name
-              + "\""
-              + " Tip: Try double-escaping spaces, for example: \"--user Last,\\\\ First\"");
-    }
+      Project.NameKey nameKey = new Project.NameKey(projectName);
 
-    final Project.NameKey nameKey = new Project.NameKey(projectName);
+      try {
+        MetaDataUpdate md = metaDataUpdateFactory.create(nameKey);
+        ProjectConfig config;
+        config = ProjectConfig.read(md);
 
-    try {
-      MetaDataUpdate md = metaDataUpdateFactory.create(nameKey);
-      ProjectConfig config;
-      config = ProjectConfig.read(md);
+        permissionGroupWidth = wide ? Integer.MAX_VALUE : columns - 9 - 5 - 9;
 
-      permissionGroupWidth = wide ? Integer.MAX_VALUE : columns - 9 - 5 - 9;
+        for (Id id : idList) {
+          userHasPermissionsInProject = false;
+          account = accountResolver.find(db, id.toString());
+          stdout.println("Full name:         " + account.getFullName());
+          // Need to know what groups the user is in. This is not a great
+          // solution, but it does work.
+          List<GroupInfo> groupInfos =
+              accountGetGroups.get().apply(
+                  new AccountResource(userFactory.create(id)));
+          HashSet<String> groupHash = new HashSet<>();
 
-      for (Id id : idList) {
-        userHasPermissionsInProject = false;
-        account = accountResolver.find(id.toString());
-        stdout.println("Full name:         " + account.getFullName());
-        // Need to know what groups the user is in. This is not a great
-        // solution, but it does work.
-        List<GroupInfo> groupInfos =
-            accountGetGroups.get().apply(
-                new AccountResource(userFactory.create(id)));
-        HashSet<String> groupHash = new HashSet<String>();
+          for (GroupInfo groupInfo : groupInfos) {
+            groupHash.add(groupInfo.name);
+          }
 
-        for (GroupInfo groupInfo : groupInfos) {
-          groupHash.add(groupInfo.name);
-        }
+          for (AccessSection accessSection : config.getAccessSections()) {
+            StringBuilder sb = new StringBuilder();
+            sb.append((String.format(sectionNameFormatter, accessSection
+                .getName().toString())));
+            // This is a solution to prevent displaying a section heading unless
+            // the user has permissions for it
+            // not the best solution, but I haven't been able to find
+            // "Is user a member of this group" based on the information I have
+            // in a more efficient manner yet.
+            userHasPermissionsInSection = false;
+            for (Permission permission : accessSection.getPermissions()) {
 
-        for (AccessSection accessSection : config.getAccessSections()) {
-          StringBuilder sb = new StringBuilder();
-          sb.append((String.format(sectionNameFormatter, accessSection
-              .getName().toString())));
-          // This is a solution to prevent displaying a section heading unless
-          // the user has permissions for it
-          // not the best solution, but I haven't been able to find
-          // "Is user a member of this group" based on the information I have
-          // in a more efficient manner yet.
-          userHasPermissionsInSection = false;
-          for (Permission permission : accessSection.getPermissions()) {
+              for (PermissionRule rule : permission.getRules()) {
 
-            for (PermissionRule rule : permission.getRules()) {
-
-              if (groupHash.contains(rule.getGroup().getName())) {
-                sb.append(String.format(ruleNameFormatter, permission.getName()));
-                sb.append(String.format(permissionNameFormatter,
-                    (!rule.getMin().equals(rule.getMax())) ? "" + rule.getMin() + " "
-                        + rule.getMax() : rule.getAction(),
-                    (permission.getExclusiveGroup() ? "EXCLUSIVE" : ""),
-                    format(rule.getGroup().getName())));
-                userHasPermissionsInSection = true;
+                if (groupHash.contains(rule.getGroup().getName())) {
+                  sb.append(String.format(ruleNameFormatter, permission.getName()));
+                  sb.append(String.format(permissionNameFormatter,
+                      (!rule.getMin().equals(rule.getMax())) ? "" + rule.getMin() + " "
+                          + rule.getMax() : rule.getAction(),
+                      (permission.getExclusiveGroup() ? "EXCLUSIVE" : ""),
+                      format(rule.getGroup().getName())));
+                  userHasPermissionsInSection = true;
+                }
               }
             }
+
+            if (userHasPermissionsInSection) {
+              stdout.print(sb.toString());
+
+              userHasPermissionsInProject = true;
+            }
           }
 
-          if (userHasPermissionsInSection) {
-            stdout.print(sb.toString());
 
-            userHasPermissionsInProject = true;
+          if (!userHasPermissionsInProject) {
+            stdout.println("  No access found for this user on this repository");
           }
         }
-
-
-        if (!userHasPermissionsInProject) {
-          stdout.println("  No access found for this user on this repository");
-        }
+      } catch (RepositoryNotFoundException e) {
+        throw new UnloggedFailure(1, "Repository not found");
       }
-    } catch (RepositoryNotFoundException e) {
-      throw new UnloggedFailure(1, "Repository not found");
     }
   }
 
-  private String format(final String s) {
+  private String format(String s) {
     if (s.length() < permissionGroupWidth) {
       return s;
-    } else {
-      return s.substring(0, permissionGroupWidth);
     }
+    return s.substring(0, permissionGroupWidth);
   }
 }
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index b4af23f..ca56b06 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -1,7 +1,7 @@
 Build
 =====
 
-This plugin is built with Buck or Maven.
+This plugin is built with Buck.
 
 Buck
 ----
@@ -101,15 +101,6 @@
   buck test --include @PLUGIN@
 ```
 
-Maven
------
-
-To build with Maven, run
-
-```
-mvn clean package
-```
-
 How to build the Gerrit Plugin API is described in the [Gerrit
 documentation](../../../Documentation/dev-buck.html#_extension_and_plugin_api_jar_files).
 
diff --git a/src/main/resources/Documentation/cmd-show-repo-access.md b/src/main/resources/Documentation/cmd-show-repo-access.md
index 7583fee..fa8d3b0 100644
--- a/src/main/resources/Documentation/cmd-show-repo-access.md
+++ b/src/main/resources/Documentation/cmd-show-repo-access.md
@@ -15,7 +15,7 @@
 DESCRIPTION
 -----------
 Displays access for a specific repository.  Does not interpret repository inheritance (currently - may change in the future, or be added as an option)
-Note, see [cmd-show-account](cmd-show-account.html) for more information on the user search functionality provided here.
+Note, see [cmd-show-account](cmd-show-account.md) for more information on the user search functionality provided here.
 
 OPTIONS
 -------
@@ -44,4 +44,4 @@
 >     $ ssh -p @SSH_PORT@ review.example.com @PLUGIN@ show-repo-access All-Projects
 
 Find Access for a repository named "my-project"
->     $ ssh -p @SSH_PORT@ review.example.com @PLUGIN@ show-repo-access my-project
\ No newline at end of file
+>     $ ssh -p @SSH_PORT@ review.example.com @PLUGIN@ show-repo-access my-project