| | |
| | | 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;
|
| | |
| | | private TimeZone timezone;
|
| | |
|
| | | private FileBasedConfig projectConfigs;
|
| | | |
| | | private MultiConfigUtil multiConfigUtil = new MultiConfigUtil();
|
| | |
|
| | | public GitBlit() {
|
| | | if (gitblit == null) {
|
| | |
| | | // TODO reconsider ownership as a user property
|
| | | // manually specify personal repository ownerships
|
| | | for (RepositoryModel rm : repositoryListCache.values()) {
|
| | | if (rm.isUsersPersonalRepository(user.username) || rm.isRepoAdministrator(user.username)) {
|
| | | if (rm.isUsersPersonalRepository(user.username) || rm.isOwner(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
|
| | |
| | | for (RepositoryModel model : getRepositoryModels(user)) {
|
| | | if (model.isUsersPersonalRepository(username)) {
|
| | | // personal repository
|
| | | model.addRepoAdministrator(user.username);
|
| | | model.addOwner(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.isRepoAdministrator(username)) {
|
| | | } else if (model.isOwner(username)) {
|
| | | // common/shared repo
|
| | | model.addRepoAdministrator(user.username);
|
| | | model.addOwner(user.username);
|
| | | updateRepositoryModel(model.name, model, false);
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | if (config != null) {
|
| | | model.description = getConfig(config, "description", "");
|
| | | model.addRepoAdministrators(multiConfigUtil.convertStringToSet(getConfig(config, "owner", "")));
|
| | | model.addOwners(ArrayUtils.fromString(getConfig(config, "owner", "")));
|
| | | model.useTickets = getConfig(config, "useTickets", false);
|
| | | model.useDocs = getConfig(config, "useDocs", false);
|
| | | model.allowForks = getConfig(config, "allowForks", true);
|
| | |
| | | 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", multiConfigUtil.convertCollectionToSingleLineString(repository.getRepoAdministrators()));
|
| | | config.setString(Constants.CONFIG_GITBLIT, null, "owner", ArrayUtils.toString(repository.owners));
|
| | | 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);
|
| | |
| | | }
|
| | |
|
| | | // schedule lucene engine
|
| | | 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);
|
| | | }
|
| | | 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.");
|
| | |
| | | // create a Gitblit repository model for the clone
|
| | | RepositoryModel cloneModel = repository.cloneAs(cloneName);
|
| | | // owner has REWIND/RW+ permissions
|
| | | cloneModel.addRepoAdministrator(user.username);
|
| | | cloneModel.addOwner(user.username);
|
| | | updateRepositoryModel(cloneName, cloneModel, false);
|
| | |
|
| | | // add the owner of the source repository to the clone's access list
|
| | | Set<String> repoAdministrators = repository.getRepoAdministrators();
|
| | | if (repoAdministrators != null) {
|
| | | for (String repoAdministrator : repoAdministrators) {
|
| | | if (!StringUtils.isEmpty(repoAdministrator)) {
|
| | | UserModel originOwner = getUserModel(repoAdministrator);
|
| | | if (!ArrayUtils.isEmpty(repository.owners)) {
|
| | | for (String owner : repository.owners) {
|
| | | UserModel originOwner = getUserModel(owner);
|
| | | if (originOwner != null) {
|
| | | originOwner.setRepositoryPermission(cloneName, AccessPermission.CLONE);
|
| | | updateUserModel(originOwner.username, originOwner, false);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|