From fb9813874c811ae06604c30d875e9dce57df9874 Mon Sep 17 00:00:00 2001
From: SHaselbauer <sarah.haselbauer@akquinet.de>
Date: Mon, 21 Jan 2013 16:28:11 -0500
Subject: [PATCH] Merge multiple owners feature (pull request #63, #66)
---
src/com/gitblit/GitBlit.java | 48 +++++++++++++++++++++++++++++++-----------------
1 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index 3eb246b..a607bd8 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -109,6 +109,7 @@
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.JsonUtils;
import com.gitblit.utils.MetricUtils;
+import com.gitblit.utils.MultiConfigUtil;
import com.gitblit.utils.ObjectCache;
import com.gitblit.utils.StringUtils;
import com.gitblit.utils.TimeUtils;
@@ -180,6 +181,8 @@
private TimeZone timezone;
private FileBasedConfig projectConfigs;
+
+ private MultiConfigUtil multiConfigUtil = new MultiConfigUtil();
public GitBlit() {
if (gitblit == null) {
@@ -822,7 +825,7 @@
// TODO reconsider ownership as a user property
// manually specify personal repository ownerships
for (RepositoryModel rm : repositoryListCache.values()) {
- if (rm.isUsersPersonalRepository(user.username) || rm.isOwner(user.username)) {
+ if (rm.isUsersPersonalRepository(user.username) || rm.isRepoAdministrator(user.username)) {
RegistrantAccessPermission rp = new RegistrantAccessPermission(rm.name, AccessPermission.REWIND,
PermissionType.OWNER, RegistrantType.REPOSITORY, null, false);
// user may be owner of a repository to which they've inherited
@@ -936,14 +939,14 @@
for (RepositoryModel model : getRepositoryModels(user)) {
if (model.isUsersPersonalRepository(username)) {
// personal repository
- model.owner = user.username;
+ model.addRepoAdministrator(user.username);
String oldRepositoryName = model.name;
model.name = "~" + user.username + model.name.substring(model.projectPath.length());
model.projectPath = "~" + user.username;
updateRepositoryModel(oldRepositoryName, model, false);
- } else if (model.isOwner(username)) {
+ } else if (model.isRepoAdministrator(username)) {
// common/shared repo
- model.owner = user.username;
+ model.addRepoAdministrator(user.username);
updateRepositoryModel(model.name, model, false);
}
}
@@ -1662,7 +1665,7 @@
if (config != null) {
model.description = getConfig(config, "description", "");
- model.owner = getConfig(config, "owner", "");
+ model.addRepoAdministrators(multiConfigUtil.convertStringToSet(getConfig(config, "owner", "")));
model.useTickets = getConfig(config, "useTickets", false);
model.useDocs = getConfig(config, "useDocs", false);
model.allowForks = getConfig(config, "allowForks", true);
@@ -2169,7 +2172,7 @@
public void updateConfiguration(Repository r, RepositoryModel repository) {
StoredConfig config = r.getConfig();
config.setString(Constants.CONFIG_GITBLIT, null, "description", repository.description);
- config.setString(Constants.CONFIG_GITBLIT, null, "owner", repository.owner);
+ config.setString(Constants.CONFIG_GITBLIT, null, "owner", multiConfigUtil.convertCollectionToSingleLineString(repository.getRepoAdministrators()));
config.setBoolean(Constants.CONFIG_GITBLIT, null, "useTickets", repository.useTickets);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "useDocs", repository.useDocs);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "allowForks", repository.allowForks);
@@ -3079,9 +3082,15 @@
}
// schedule lucene engine
- logger.info("Lucene executor is scheduled to process indexed branches every 2 minutes.");
- scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, 2, TimeUnit.MINUTES);
-
+ boolean branchIndexingActivated = settings.getBoolean(
+ Keys.git.branchIndexingActivated, true);
+ logger.info("Branch indexing is "
+ + (branchIndexingActivated ? "" : "not") + " activated");
+ if (branchIndexingActivated) {
+ logger.info("Lucene executor is scheduled to process indexed branches every 2 minutes.");
+ scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, 2,
+ TimeUnit.MINUTES);
+ }
// schedule gc engine
if (gcExecutor.isReady()) {
logger.info("GC executor is scheduled to scan repositories every 24 hours.");
@@ -3249,18 +3258,23 @@
// create a Gitblit repository model for the clone
RepositoryModel cloneModel = repository.cloneAs(cloneName);
- // owner has REWIND/RW+ permissions
- cloneModel.owner = user.username;
+ // owner has REWIND/RW+ permissions
+ cloneModel.addRepoAdministrator(user.username);
updateRepositoryModel(cloneName, cloneModel, false);
// add the owner of the source repository to the clone's access list
- if (!StringUtils.isEmpty(repository.owner)) {
- UserModel originOwner = getUserModel(repository.owner);
- if (originOwner != null) {
- originOwner.setRepositoryPermission(cloneName, AccessPermission.CLONE);
- updateUserModel(originOwner.username, originOwner, false);
+ Set<String> repoAdministrators = repository.getRepoAdministrators();
+ if (repoAdministrators != null) {
+ for (String repoAdministrator : repoAdministrators) {
+ if (!StringUtils.isEmpty(repoAdministrator)) {
+ UserModel originOwner = getUserModel(repoAdministrator);
+ if (originOwner != null) {
+ originOwner.setRepositoryPermission(cloneName, AccessPermission.CLONE);
+ updateUserModel(originOwner.username, originOwner, false);
+ }
+ }
}
- }
+ }
// grant origin's user list clone permission to fork
List<String> users = getRepositoryUsers(repository);
--
Gitblit v1.9.1