From f76fee63ed9cb3a30d3c0c092d860b1cb93a481b Mon Sep 17 00:00:00 2001
From: Gerard Smyth <gerard.smyth@gmail.com>
Date: Thu, 08 May 2014 13:09:30 -0400
Subject: [PATCH] Updated the SyndicationServlet to provide an additional option to return details of the tags in the repository instead of the commits. This uses a new 'ot' request parameter to indicate the object type of the content to return, which can be ither TAG or COMMIT. If this is not provided, then COMMIT is assumed to maintain backwards compatability. If tags are returned, then the paging parameters, 'l' and 'pg' are still supported, but searching options are currently ignored.
---
src/main/java/com/gitblit/manager/RepositoryManager.java | 68 +++++++++++++++++++++++++++------
1 files changed, 55 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/gitblit/manager/RepositoryManager.java b/src/main/java/com/gitblit/manager/RepositoryManager.java
index e412deb..7351eb9 100644
--- a/src/main/java/com/gitblit/manager/RepositoryManager.java
+++ b/src/main/java/com/gitblit/manager/RepositoryManager.java
@@ -421,8 +421,9 @@
// update the fork origin repository with this repository clone
if (!StringUtils.isEmpty(model.originRepository)) {
- if (repositoryListCache.containsKey(model.originRepository)) {
- RepositoryModel origin = repositoryListCache.get(model.originRepository);
+ String originKey = model.originRepository.toLowerCase();
+ if (repositoryListCache.containsKey(originKey)) {
+ RepositoryModel origin = repositoryListCache.get(originKey);
origin.addFork(model.name);
}
}
@@ -451,6 +452,18 @@
repositorySizeCache.remove(repositoryName);
repositoryMetricsCache.remove(repositoryName);
CommitCache.instance().clear(repositoryName);
+ }
+
+ /**
+ * Reset all caches for this repository.
+ *
+ * @param repositoryName
+ * @since 1.5.1
+ */
+ @Override
+ public void resetRepositoryCache(String repositoryName) {
+ removeFromCachedRepositoryList(repositoryName);
+ clearRepositoryMetadataCache(repositoryName);
}
/**
@@ -534,8 +547,9 @@
// rebuild fork networks
for (RepositoryModel model : repositoryListCache.values()) {
if (!StringUtils.isEmpty(model.originRepository)) {
- if (repositoryListCache.containsKey(model.originRepository)) {
- RepositoryModel origin = repositoryListCache.get(model.originRepository);
+ String originKey = model.originRepository.toLowerCase();
+ if (repositoryListCache.containsKey(originKey)) {
+ RepositoryModel origin = repositoryListCache.get(originKey);
origin.addFork(model.name);
}
}
@@ -785,10 +799,11 @@
model.projectPath = StringUtils.getFirstPathElement(repositoryName);
StoredConfig config = r.getConfig();
- boolean hasOrigin = !StringUtils.isEmpty(config.getString("remote", "origin", "url"));
+ boolean hasOrigin = false;
if (config != null) {
// Initialize description from description file
+ hasOrigin = !StringUtils.isEmpty(config.getString("remote", "origin", "url"));
if (getConfig(config,"description", null) == null) {
File descFile = new File(r.getDirectory(), "description");
if (descFile.exists()) {
@@ -801,6 +816,10 @@
model.description = getConfig(config, "description", "");
model.originRepository = getConfig(config, "originRepository", null);
model.addOwners(ArrayUtils.fromString(getConfig(config, "owner", "")));
+ model.acceptNewPatchsets = getConfig(config, "acceptNewPatchsets", true);
+ model.acceptNewTickets = getConfig(config, "acceptNewTickets", true);
+ model.requireApproval = getConfig(config, "requireApproval", settings.getBoolean(Keys.tickets.requireApproval, false));
+ model.mergeTo = getConfig(config, "mergeTo", null);
model.useIncrementalPushTags = getConfig(config, "useIncrementalPushTags", false);
model.incrementalPushTagPrefix = getConfig(config, "incrementalPushTagPrefix", null);
model.allowForks = getConfig(config, "allowForks", true);
@@ -851,6 +870,9 @@
}
}
model.HEAD = JGitUtils.getHEADRef(r);
+ if (StringUtils.isEmpty(model.mergeTo)) {
+ model.mergeTo = model.HEAD;
+ }
model.availableRefs = JGitUtils.getAvailableHeadTargets(r);
model.sparkleshareId = JGitUtils.getSparkleshareId(r);
model.hasCommits = JGitUtils.hasCommits(r);
@@ -935,26 +957,31 @@
*/
@Override
public String getFork(String username, String origin) {
+ if (StringUtils.isEmpty(origin)) {
+ return null;
+ }
String userProject = ModelUtils.getPersonalPath(username);
if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) {
+ String originKey = origin.toLowerCase();
String userPath = userProject + "/";
// collect all origin nodes in fork network
Set<String> roots = new HashSet<String>();
- roots.add(origin);
- RepositoryModel originModel = repositoryListCache.get(origin);
+ roots.add(originKey);
+ RepositoryModel originModel = repositoryListCache.get(originKey);
while (originModel != null) {
if (!ArrayUtils.isEmpty(originModel.forks)) {
for (String fork : originModel.forks) {
if (!fork.startsWith(userPath)) {
- roots.add(fork);
+ roots.add(fork.toLowerCase());
}
}
}
if (originModel.originRepository != null) {
- roots.add(originModel.originRepository);
- originModel = repositoryListCache.get(originModel.originRepository);
+ String ooKey = originModel.originRepository.toLowerCase();
+ roots.add(ooKey);
+ originModel = repositoryListCache.get(ooKey);
} else {
// break
originModel = null;
@@ -965,7 +992,7 @@
if (repository.startsWith(userPath)) {
RepositoryModel model = repositoryListCache.get(repository);
if (!StringUtils.isEmpty(model.originRepository)) {
- if (roots.contains(model.originRepository)) {
+ if (roots.contains(model.originRepository.toLowerCase())) {
// user has a fork in this graph
return model.name;
}
@@ -1005,7 +1032,7 @@
// find the root, cached
RepositoryModel model = repositoryListCache.get(repository.toLowerCase());
while (model.originRepository != null) {
- model = repositoryListCache.get(model.originRepository);
+ model = repositoryListCache.get(model.originRepository.toLowerCase());
}
ForkModel root = getForkModelFromCache(model.name);
return root;
@@ -1336,7 +1363,7 @@
// update this repository's origin's fork list
if (!StringUtils.isEmpty(repository.originRepository)) {
- RepositoryModel origin = repositoryListCache.get(repository.originRepository);
+ RepositoryModel origin = repositoryListCache.get(repository.originRepository.toLowerCase());
if (origin != null && !ArrayUtils.isEmpty(origin.forks)) {
origin.forks.remove(repositoryName);
origin.forks.add(repository.name);
@@ -1406,6 +1433,18 @@
config.setString(Constants.CONFIG_GITBLIT, null, "description", repository.description);
config.setString(Constants.CONFIG_GITBLIT, null, "originRepository", repository.originRepository);
config.setString(Constants.CONFIG_GITBLIT, null, "owner", ArrayUtils.toString(repository.owners));
+ config.setBoolean(Constants.CONFIG_GITBLIT, null, "acceptNewPatchsets", repository.acceptNewPatchsets);
+ config.setBoolean(Constants.CONFIG_GITBLIT, null, "acceptNewTickets", repository.acceptNewTickets);
+ if (settings.getBoolean(Keys.tickets.requireApproval, false) == repository.requireApproval) {
+ // use default
+ config.unset(Constants.CONFIG_GITBLIT, null, "requireApproval");
+ } else {
+ // override default
+ config.setBoolean(Constants.CONFIG_GITBLIT, null, "requireApproval", repository.requireApproval);
+ }
+ if (!StringUtils.isEmpty(repository.mergeTo)) {
+ config.setString(Constants.CONFIG_GITBLIT, null, "mergeTo", repository.mergeTo);
+ }
config.setBoolean(Constants.CONFIG_GITBLIT, null, "useIncrementalPushTags", repository.useIncrementalPushTags);
if (StringUtils.isEmpty(repository.incrementalPushTagPrefix) ||
repository.incrementalPushTagPrefix.equals(settings.getString(Keys.git.defaultIncrementalPushTagPrefix, "r"))) {
@@ -1802,6 +1841,9 @@
protected void confirmWriteAccess() {
if (runtimeManager.isServingRepositories()) {
try {
+ if (!getRepositoriesFolder().exists()) {
+ getRepositoriesFolder().mkdirs();
+ }
File file = File.createTempFile(".test-", ".txt", getRepositoriesFolder());
file.delete();
} catch (Exception e) {
--
Gitblit v1.9.1