From c25dbf0bb721bbb6e1c37707d08bec324e1b661b Mon Sep 17 00:00:00 2001
From: Stardrad Yin <yin8086@gmail.com>
Date: Wed, 05 Mar 2014 21:45:43 -0500
Subject: [PATCH] Add Chinese translations for new strings, and fix translations based on online page views of dev.gitblit.com
---
src/main/java/com/gitblit/utils/ActivityUtils.java | 76 +++++++++++++++++++++++--------------
1 files changed, 47 insertions(+), 29 deletions(-)
diff --git a/src/main/java/com/gitblit/utils/ActivityUtils.java b/src/main/java/com/gitblit/utils/ActivityUtils.java
index 1792bf2..3a54d33 100644
--- a/src/main/java/com/gitblit/utils/ActivityUtils.java
+++ b/src/main/java/com/gitblit/utils/ActivityUtils.java
@@ -27,14 +27,16 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.TimeZone;
+import java.util.TreeSet;
import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.revwalk.RevCommit;
-import com.gitblit.GitBlit;
+import com.gitblit.IStoredSettings;
+import com.gitblit.Keys;
+import com.gitblit.manager.IRepositoryManager;
import com.gitblit.models.Activity;
import com.gitblit.models.GravatarProfile;
import com.gitblit.models.RefModel;
@@ -44,16 +46,20 @@
/**
* Utility class for building activity information from repositories.
- *
+ *
* @author James Moger
- *
+ *
*/
public class ActivityUtils {
/**
* Gets the recent activity from the repositories for the last daysBack days
* on the specified branch.
- *
+ *
+ * @param settings
+ * the runtime settings
+ * @param repositoryManager
+ * the repository manager
* @param models
* the list of repositories to query
* @param daysBack
@@ -65,8 +71,13 @@
* the timezone for aggregating commits
* @return
*/
- public static List<Activity> getRecentActivity(List<RepositoryModel> models, int daysBack,
- String objectId, TimeZone timezone) {
+ public static List<Activity> getRecentActivity(
+ IStoredSettings settings,
+ IRepositoryManager repositoryManager,
+ List<RepositoryModel> models,
+ int daysBack,
+ String objectId,
+ TimeZone timezone) {
// Activity panel shows last daysBack of activity across all
// repositories.
@@ -79,9 +90,18 @@
Calendar cal = Calendar.getInstance();
cal.setTimeZone(timezone);
+ // aggregate author exclusions
+ Set<String> authorExclusions = new TreeSet<String>();
+ authorExclusions.addAll(settings.getStrings(Keys.web.metricAuthorExclusions));
+ for (RepositoryModel model : models) {
+ if (!ArrayUtils.isEmpty(model.metricAuthorExclusions)) {
+ authorExclusions.addAll(model.metricAuthorExclusions);
+ }
+ }
+
Map<String, Activity> activity = new HashMap<String, Activity>();
for (RepositoryModel model : models) {
- if (model.maxActivityCommits == -1) {
+ if (!model.isShowActivity()) {
// skip this repository
continue;
}
@@ -89,33 +109,33 @@
if (model.isCollectingGarbage) {
continue;
}
- Repository repository = GitBlit.self()
- .getRepository(model.name);
+ Repository repository = repositoryManager.getRepository(model.name);
List<String> branches = new ArrayList<String>();
if (StringUtils.isEmpty(objectId)) {
for (RefModel local : JGitUtils.getLocalBranches(
repository, true, -1)) {
+ if (!local.getDate().after(thresholdDate)) {
+ // branch not recently updated
+ continue;
+ }
branches.add(local.getName());
}
} else {
branches.add(objectId);
}
- Map<ObjectId, List<RefModel>> allRefs = JGitUtils
- .getAllRefs(repository, model.showRemoteBranches);
for (String branch : branches) {
String shortName = branch;
if (shortName.startsWith(Constants.R_HEADS)) {
shortName = shortName.substring(Constants.R_HEADS.length());
}
- List<RevCommit> commits = JGitUtils.getRevLog(repository,
- branch, thresholdDate);
+ List<RepositoryCommit> commits = CommitCache.instance().getCommits(model.name, repository, branch, thresholdDate);
if (model.maxActivityCommits > 0 && commits.size() > model.maxActivityCommits) {
// trim commits to maximum count
commits = commits.subList(0, model.maxActivityCommits);
}
- for (RevCommit commit : commits) {
- Date date = JGitUtils.getCommitDate(commit);
+ for (RepositoryCommit commit : commits) {
+ Date date = commit.getCommitDate();
String dateStr = df.format(date);
if (!activity.containsKey(dateStr)) {
// Normalize the date to midnight
@@ -124,16 +144,14 @@
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
- activity.put(dateStr, new Activity(cal.getTime()));
+ Activity a = new Activity(cal.getTime());
+ a.excludeAuthors(authorExclusions);
+ activity.put(dateStr, a);
}
- RepositoryCommit commitModel = activity.get(dateStr)
- .addCommit(model.name, shortName, commit);
- if (commitModel != null) {
- commitModel.setRefs(allRefs.get(commit.getId()));
- }
+ activity.get(dateStr).addCommit(commit);
}
}
-
+
// close the repository
repository.close();
}
@@ -146,7 +164,7 @@
/**
* Returns the Gravatar profile, if available, for the specified email
* address.
- *
+ *
* @param emailaddress
* @return a Gravatar Profile
* @throws IOException
@@ -158,7 +176,7 @@
/**
* Creates a Gravatar thumbnail url from the specified email address.
- *
+ *
* @param email
* address to query Gravatar
* @param width
@@ -174,10 +192,10 @@
"https://www.gravatar.com/avatar/{0}?s={1,number,0}&d=identicon", emailHash, width);
return url;
}
-
+
/**
* Creates a Gravatar thumbnail url from the specified email address.
- *
+ *
* @param email
* address to query Gravatar
* @param width
@@ -197,7 +215,7 @@
/**
* Returns the Gravatar profile, if available, for the specified hashcode.
* address.
- *
+ *
* @param hash
* the hash of the email address
* @return a Gravatar Profile
--
Gitblit v1.9.1