Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
Notification: improve new commits message
Browse files Browse the repository at this point in the history
Applied i18n and markdown markup on new commits message.
  • Loading branch information
laziel committed Aug 14, 2014
1 parent 92ef3fc commit 8ccf0ac
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
5 changes: 3 additions & 2 deletions app/actors/CommitsNotificationActor.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import models.*;
import org.eclipse.jgit.revwalk.RevCommit;
import play.i18n.Messages;

import java.util.List;
import java.util.Set;
Expand All @@ -44,9 +45,9 @@ void doReceive(PostReceiveMessage message) {

String title;
if(refNames.size() == 1) {
title = String.format("[%s] pushed %d commits to %s.", project.name, commits.size(), refNames.get(0));
title = Messages.get("notification.pushed.commits.to", project.name, commits.size(), refNames.get(0));
} else {
title = String.format("[%s] pushed %d commits.", project.name, commits.size());
title = Messages.get("notification.pushed.commits", project.name, commits.size());
}

Set<User> watchers = Watch.findWatchers(project.asResource());
Expand Down
15 changes: 12 additions & 3 deletions app/models/NotificationEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@
import javax.persistence.*;
import javax.servlet.ServletException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.net.URLEncoder;

import static models.enumeration.EventType.*;

Expand Down Expand Up @@ -662,20 +664,27 @@ private static String newCommitsMessage(List<RevCommit> commits, List<String> re
StringBuilder result = new StringBuilder();

if(commits.size() > 0) {
result.append("New Commits: \n");
result.append("### " + Messages.get("notification.pushed.newcommits") + "\n");
result.append("```\n");
for(RevCommit commit : commits) {
GitCommit gitCommit = new GitCommit(commit);
result.append(gitCommit.getShortId());
result.append(" ");
result.append(gitCommit.getShortMessage());
result.append("\n");
}
result.append("```\n\n");
}

if(refNames.size() > 0) {
result.append("Branches: \n");
result.append("### " + Messages.get("notification.pushed.branches") + "\n");

for(String refName: refNames) {
result.append(refName);
try {
result.append("[" + refName + "](" + routes.CodeHistoryApp.history(project.owner, project.name, URLEncoder.encode(refName, "UTF-8"), "") + ")");
} catch(UnsupportedEncodingException e){
result.append(refName);
}
result.append("\n");
}
}
Expand Down
4 changes: 4 additions & 0 deletions conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ notification.pullrequest.merged = Pull Request merged
notification.pullrequest.reopened = Pull Request has been reopened
notification.pullrequest.reviewed = {0} completed a review on pull request.
notification.pullrequest.unreviewed = {0} withdraw a review on pull request.
notification.pushed.branches = Branches
notification.pushed.commits = [{0}] pushed {1} commits
notification.pushed.commits.to = [{0}] pushed {1} commits to {2}
notification.pushed.newcommits = New Commits
notification.reviewthread.closed = Review thread closed.
notification.reviewthread.reopened = Review thread reopened
notification.type.issue.assignee.changed = Issue assignee changed.
Expand Down
4 changes: 4 additions & 0 deletions conf/messages.ko
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ notification.pullrequest.merged = 보낸 코드가 반영됨(merged)
notification.pullrequest.reopened = 코드 주고받기 다시 열림
notification.pullrequest.reviewed = {0} 님이 리뷰를 완료했습니다.
notification.pullrequest.unreviewed = {0} 님이 리뷰를 취소했습니다.
notification.pushed.branches = 브랜치
notification.pushed.commits = [{0}] {1}개의 커밋이 푸시 되었습니다
notification.pushed.commits.to = [{0}] {1}개의 커밋이 브랜치 {2}로 푸시 되었습니다
notification.pushed.newcommits = 커밋
notification.reviewthread.closed = 리뷰 스레드 닫힘
notification.reviewthread.reopened = 리뷰 스레드 다시 열림
notification.type.issue.assignee.changed = 이슈 담당자 변경
Expand Down

0 comments on commit 8ccf0ac

Please sign in to comment.