Class BanCommit

java.lang.Object
com.google.gerrit.server.git.BanCommit

public class BanCommit extends Object
Logic for banning commits from being uploaded.

Gerrit has a per-project list of commits that are forbidden to be pushed. This class reads and writes the banned commits list in refs/meta/reject-commits.

  • Method Details

    • loadRejectCommitsMap

      public static org.eclipse.jgit.notes.NoteMap loadRejectCommitsMap(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.revwalk.RevWalk walk) throws IOException
      Loads a list of commits to reject from refs/meta/reject-commits.
      Parameters:
      repo - repository from which the rejected commits should be loaded
      walk - open revwalk on repo.
      Returns:
      NoteMap of commits to be rejected, null if there are none.
      Throws:
      IOException - the map cannot be loaded.
    • ban

      public BanCommitResult ban(Project.NameKey project, CurrentUser user, List<org.eclipse.jgit.lib.ObjectId> commitsToBan, String reason) throws AuthException, IOException, PermissionBackendException
      Bans a list of commits from the given project.

      The user must be specified, so it can be checked for the BAN_COMMIT permission.

      Throws:
      AuthException
      IOException
      PermissionBackendException