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/RefLogUtils.java | 46 ++++++++++++++++++++++++++++++++++++----------
1 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/gitblit/utils/RefLogUtils.java b/src/main/java/com/gitblit/utils/RefLogUtils.java
index af24773..a87579f 100644
--- a/src/main/java/com/gitblit/utils/RefLogUtils.java
+++ b/src/main/java/com/gitblit/utils/RefLogUtils.java
@@ -213,6 +213,22 @@
*/
public static boolean updateRefLog(UserModel user, Repository repository,
Collection<ReceiveCommand> commands) {
+
+ // only track branches and tags
+ List<ReceiveCommand> filteredCommands = new ArrayList<ReceiveCommand>();
+ for (ReceiveCommand cmd : commands) {
+ if (!cmd.getRefName().startsWith(Constants.R_HEADS)
+ && !cmd.getRefName().startsWith(Constants.R_TAGS)) {
+ continue;
+ }
+ filteredCommands.add(cmd);
+ }
+
+ if (filteredCommands.isEmpty()) {
+ // nothing to log
+ return true;
+ }
+
RefModel reflogBranch = getRefLogBranch(repository);
if (reflogBranch == null) {
JGitUtils.createOrphanBranch(repository, GB_REFLOG, null);
@@ -443,7 +459,15 @@
Date date = push.getAuthorIdent().getWhen();
RefLogEntry log = new RefLogEntry(repositoryName, date, user);
- List<PathChangeModel> changedRefs = JGitUtils.getFilesInCommit(repository, push);
+
+ // only report HEADS and TAGS for now
+ List<PathChangeModel> changedRefs = new ArrayList<PathChangeModel>();
+ for (PathChangeModel refChange : JGitUtils.getFilesInCommit(repository, push)) {
+ if (refChange.path.startsWith(Constants.R_HEADS)
+ || refChange.path.startsWith(Constants.R_TAGS)) {
+ changedRefs.add(refChange);
+ }
+ }
if (changedRefs.isEmpty()) {
// skip empty commits
continue;
@@ -454,8 +478,6 @@
case DELETE:
log.updateRef(change.path, ReceiveCommand.Type.DELETE);
break;
- case ADD:
- log.updateRef(change.path, ReceiveCommand.Type.CREATE);
default:
String content = JGitUtils.getStringContent(repository, push.getTree(), change.path);
String [] fields = content.split(" ");
@@ -466,12 +488,16 @@
// ref deletion
continue;
}
- List<RevCommit> pushedCommits = JGitUtils.getRevLog(repository, oldId, newId);
- for (RevCommit pushedCommit : pushedCommits) {
- RepositoryCommit repoCommit = log.addCommit(change.path, pushedCommit);
- if (repoCommit != null) {
- repoCommit.setRefs(allRefs.get(pushedCommit.getId()));
+ try {
+ List<RevCommit> pushedCommits = JGitUtils.getRevLog(repository, oldId, newId);
+ for (RevCommit pushedCommit : pushedCommits) {
+ RepositoryCommit repoCommit = log.addCommit(change.path, pushedCommit);
+ if (repoCommit != null) {
+ repoCommit.setRefs(allRefs.get(pushedCommit.getId()));
+ }
}
+ } catch (Exception e) {
+
}
}
}
@@ -642,7 +668,7 @@
if (ref.getName().startsWith(Constants.R_TAGS)) {
// treat tags as special events in the log
if (!tags.containsKey(dateStr)) {
- UserModel tagUser = newUserModelFrom(commit.getAuthorIdent());
+ UserModel tagUser = newUserModelFrom(ref.getAuthorIdent());
Date tagDate = commit.getAuthorIdent().getWhen();
tags.put(dateStr, new DailyLogEntry(repositoryName, tagDate, tagUser));
}
@@ -653,7 +679,7 @@
} else if (ref.getName().startsWith(Constants.R_PULL)) {
// treat pull requests as special events in the log
if (!pulls.containsKey(dateStr)) {
- UserModel commitUser = newUserModelFrom(commit.getAuthorIdent());
+ UserModel commitUser = newUserModelFrom(ref.getAuthorIdent());
Date commitDate = commit.getAuthorIdent().getWhen();
pulls.put(dateStr, new DailyLogEntry(repositoryName, commitDate, commitUser));
}
--
Gitblit v1.9.1