import com.gitblit.models.GitClientApplication;
import com.gitblit.models.Metric;
import com.gitblit.models.ProjectModel;
+import com.gitblit.models.RefModel;
import com.gitblit.models.RegistrantAccessPermission;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.RepositoryUrl;
configureJGit();
configureFanout();
configureGitDaemon();
-
- CommitCache.instance().setCacheDays(settings.getInteger(Keys.web.activityCacheDays, 14));
-
+ configureCommitCache();
+
ContainerUtils.CVE_2007_0450.test();
}
}
}
+ protected void configureCommitCache() {
+ int daysToCache = settings.getInteger(Keys.web.activityCacheDays, 14);
+ if (daysToCache <= 0) {
+ logger.info("commit cache disabled");
+ } else {
+ long start = System.nanoTime();
+ long repoCount = 0;
+ long commitCount = 0;
+ logger.info(MessageFormat.format("preparing {0} day commit cache. please wait...", daysToCache));
+ CommitCache.instance().setCacheDays(daysToCache);
+ Date cutoff = CommitCache.instance().getCutoffDate();
+ for (String repositoryName : getRepositoryList()) {
+ RepositoryModel model = getRepositoryModel(repositoryName);
+ if (model.hasCommits && model.lastChange.after(cutoff)) {
+ repoCount++;
+ Repository repository = getRepository(repositoryName);
+ for (RefModel ref : JGitUtils.getLocalBranches(repository, true, -1)) {
+ if (!ref.getDate().after(cutoff)) {
+ // branch not recently updated
+ continue;
+ }
+ List<?> commits = CommitCache.instance().getCommits(repositoryName, repository, ref.getName());
+ if (commits.size() > 0) {
+ logger.info(MessageFormat.format(" cached {0} commits for {1}:{2}",
+ commits.size(), repositoryName, ref.getName()));
+ commitCount += commits.size();
+ }
+ }
+ repository.close();
+ }
+ }
+ logger.info(MessageFormat.format("built {0} day commit cache of {1} commits across {2} repositories in {3} msecs",
+ daysToCache, commitCount, repoCount, TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start)));
+ }
+ }
+
protected final Logger getLogger() {
return logger;
}
if (StringUtils.isEmpty(objectId)) {\r
for (RefModel local : JGitUtils.getLocalBranches(\r
repository, true, -1)) {\r
+ if (!local.getDate().after(thresholdDate)) {\r
+ // branch not recently updated\r
+ continue;\r
+ }\r
branches.add(local.getName());\r
}\r
} else {\r
*
* @return
*/
- protected Date getCacheCutoffDate() {
+ public Date getCutoffDate() {
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
cal.set(Calendar.HOUR_OF_DAY, 0);
* @return a list of commits
*/
public List<RepositoryCommit> getCommits(String repositoryName, Repository repository, String branch) {
- return getCommits(repositoryName, repository, branch, getCacheCutoffDate());
+ return getCommits(repositoryName, repository, branch, getCutoffDate());
}
/**
*/
public List<RepositoryCommit> getCommits(String repositoryName, Repository repository, String branch, Date sinceDate) {
long start = System.nanoTime();
- Date cacheCutoffDate = getCacheCutoffDate();
+ Date cacheCutoffDate = getCutoffDate();
List<RepositoryCommit> list;
if (cacheDays > 0 && (sinceDate.getTime() >= cacheCutoffDate.getTime())) {
// request fits within the cache window
Map<String, DailyLogEntry> dailydigests = new HashMap<String, DailyLogEntry>();
String linearParent = null;
for (RefModel local : JGitUtils.getLocalBranches(repository, true, -1)) {
+ if (!local.getDate().after(minimumDate)) {
+ // branch not recently updated
+ continue;
+ }
String branch = local.getName();
List<RepositoryCommit> commits = CommitCache.instance().getCommits(repositoryName, repository, branch, minimumDate);
for (RepositoryCommit commit : commits) {
package com.gitblit.wicket.pages;\r
\r
import java.io.Serializable;\r
-import java.text.DateFormat;\r
import java.text.MessageFormat;\r
-import java.text.SimpleDateFormat;\r
import java.util.ArrayList;\r
import java.util.Calendar;\r
import java.util.Collection;\r
import com.gitblit.wicket.charting.GoogleChart;\r
import com.gitblit.wicket.charting.GoogleCharts;\r
import com.gitblit.wicket.charting.GooglePieChart;\r
-import com.gitblit.wicket.ng.NgController;\r
import com.gitblit.wicket.panels.DigestsPanel;\r
import com.gitblit.wicket.panels.LinkPanel;\r
\r
// create daily commit digest feed\r
List<DailyLogEntry> digests = new ArrayList<DailyLogEntry>();\r
for (RepositoryModel model : repositories) {\r
- Repository repository = GitBlit.self().getRepository(model.name);\r
- List<DailyLogEntry> entries = RefLogUtils.getDailyLogByRef(model.name, repository, minimumDate, timezone);\r
- digests.addAll(entries);\r
- repository.close();\r
+ if (model.isCollectingGarbage) {\r
+ continue;\r
+ }\r
+ if (model.hasCommits && model.lastChange.after(minimumDate)) {\r
+ Repository repository = GitBlit.self().getRepository(model.name);\r
+ List<DailyLogEntry> entries = RefLogUtils.getDailyLogByRef(model.name, repository, minimumDate, timezone);\r
+ digests.addAll(entries);\r
+ repository.close();\r
+ }\r
}\r
\r
Fragment activityFragment = new Fragment("activity", "activityFragment", this);\r