diff options
author | James Moger <james.moger@gitblit.com> | 2013-05-25 00:34:25 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-05-25 00:34:25 -0400 |
commit | 5c1588395c1ae15d770fc4ee4092a055abd6038b (patch) | |
tree | 3151f155c93550e4d1f0b5df36d89f53bbe7a74b /src/main/java/com/gitblit/utils/PushLogUtils.java | |
parent | 325310ddb0970fc26833045efd624cde7b5c44ad (diff) | |
download | gitblit-5c1588395c1ae15d770fc4ee4092a055abd6038b.tar.gz gitblit-5c1588395c1ae15d770fc4ee4092a055abd6038b.zip |
Enhance push log utils api with functional date filtering
Diffstat (limited to 'src/main/java/com/gitblit/utils/PushLogUtils.java')
-rw-r--r-- | src/main/java/com/gitblit/utils/PushLogUtils.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/utils/PushLogUtils.java b/src/main/java/com/gitblit/utils/PushLogUtils.java index e9605724..2f076fb5 100644 --- a/src/main/java/com/gitblit/utils/PushLogUtils.java +++ b/src/main/java/com/gitblit/utils/PushLogUtils.java @@ -438,4 +438,42 @@ public class PushLogUtils { return refPushLog; } + + /** + * Returns the list of pushes separated by ref (e.g. each ref has it's own + * PushLogEntry object). + * + * @param repositoryName + * @param repository + * @param minimumDate + * @return a list of push log entries separated by ref + */ + public static List<PushLogEntry> getPushLogByRef(String repositoryName, Repository repository, Date minimumDate) { + // break the push log into ref push logs and then merge them back into a list + Map<String, List<PushLogEntry>> refMap = new HashMap<String, List<PushLogEntry>>(); + for (PushLogEntry push : getPushLog(repositoryName, repository, minimumDate)) { + for (String ref : push.getChangedRefs()) { + if (!refMap.containsKey(ref)) { + refMap.put(ref, new ArrayList<PushLogEntry>()); + } + + // construct new ref-specific push log entry + PushLogEntry refPush = new PushLogEntry(push.repository, push.date, push.user); + refPush.updateRef(ref, push.getChangeType(ref), push.getOldId(ref), push.getNewId(ref)); + refPush.addCommits(push.getCommits(ref)); + refMap.get(ref).add(refPush); + } + } + + // merge individual ref pushes into master list + List<PushLogEntry> refPushLog = new ArrayList<PushLogEntry>(); + for (List<PushLogEntry> refPush : refMap.values()) { + refPushLog.addAll(refPush); + } + + // sort ref push log + Collections.sort(refPushLog); + + return refPushLog; + } } |