From 194f62ab059216991a841e5a2a42bededcd1605c Mon Sep 17 00:00:00 2001 From: Arthur Ouyang Date: Wed, 18 Nov 2015 18:55:50 +0800 Subject: [PATCH] Fix the hyperlink and the name of the branch #1965 The hyperlink and the display name of the branch if the branch is in a folder or the branch name has '#' --- conf/locale/locale_bg-BG.ini | 2 +- conf/locale/locale_de-DE.ini | 2 +- conf/locale/locale_en-US.ini | 2 +- conf/locale/locale_es-ES.ini | 2 +- conf/locale/locale_fr-FR.ini | 2 +- conf/locale/locale_it-IT.ini | 2 +- conf/locale/locale_ja-JP.ini | 2 +- conf/locale/locale_lv-LV.ini | 2 +- conf/locale/locale_nl-NL.ini | 2 +- conf/locale/locale_pl-PL.ini | 2 +- conf/locale/locale_pt-BR.ini | 2 +- conf/locale/locale_ru-RU.ini | 2 +- conf/locale/locale_zh-CN.ini | 2 +- conf/locale/locale_zh-HK.ini | 2 +- modules/git/utils.go | 4 ++++ templates/user/dashboard/feeds.tmpl | 3 ++- 16 files changed, 20 insertions(+), 15 deletions(-) diff --git a/conf/locale/locale_bg-BG.ini b/conf/locale/locale_bg-BG.ini index 00342a196..f5e1453c2 100755 --- a/conf/locale/locale_bg-BG.ini +++ b/conf/locale/locale_bg-BG.ini @@ -957,7 +957,7 @@ notices.delete_success=Системното съобщение е изтрито [action] create_repo=създаде хранилище %s rename_repo=преименува хранилище от %[1]s на %[3]s -commit_repo=предаде към %[2]s в %[3]s +commit_repo=предаде към %[3]s в %[4]s create_issue=`отвори проблем %s#%[2]s"` create_pull_request=`създаде заявка за сливане %s#%[2]s` comment_issue=`коментира проблем %s#%[2]s"` diff --git a/conf/locale/locale_de-DE.ini b/conf/locale/locale_de-DE.ini index 33965aa5d..81dafac83 100755 --- a/conf/locale/locale_de-DE.ini +++ b/conf/locale/locale_de-DE.ini @@ -957,7 +957,7 @@ notices.delete_success=System-Mitteilung erfolgreich gelöscht. [action] create_repo=hat Repository %s erstellt rename_repo=das Repository wurde umbenannt von %[1]s zu %[3]s -commit_repo=hat nach %[2]s in %[3]s gepusht +commit_repo=hat nach %[3]s in %[4]s gepusht create_issue=`hat Issue %s#%[2]s eröffnet` create_pull_request=`Pull-Anforderung erstellt %s#%[2]s` comment_issue=`hat Issue %s#%[2]s kommentiert` diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index efeb4ff9b..6a74d1a79 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -962,7 +962,7 @@ notices.delete_success = System notice has been deleted successfully. [action] create_repo = created repository %s rename_repo = renamed repository from %[1]s to %[3]s -commit_repo = pushed to %[2]s at %[3]s +commit_repo = pushed to %[3]s at %[4]s create_issue = `opened issue %s#%[2]s` create_pull_request = `created pull request %s#%[2]s` comment_issue = `commented on issue %s#%[2]s` diff --git a/conf/locale/locale_es-ES.ini b/conf/locale/locale_es-ES.ini index 3376d55a3..0b8827865 100755 --- a/conf/locale/locale_es-ES.ini +++ b/conf/locale/locale_es-ES.ini @@ -957,7 +957,7 @@ notices.delete_success=La notificación del sistema se ha eliminado correctament [action] create_repo=repositorio creado %s rename_repo=repositorio renombrado de %[1]s a %[3]s -commit_repo=hizo push a %[2]s en %[3]s +commit_repo=hizo push a %[3]s en %[4]s create_issue=`incidencia abierta %s#%[2]s` create_pull_request=`creado pull request %s#%[2]s` comment_issue=`comentó en la incidencia %s#%[2]s` diff --git a/conf/locale/locale_fr-FR.ini b/conf/locale/locale_fr-FR.ini index 5e7ebbd2d..75afdbf46 100755 --- a/conf/locale/locale_fr-FR.ini +++ b/conf/locale/locale_fr-FR.ini @@ -957,7 +957,7 @@ notices.delete_success=Note système supprimée avec succès. [action] create_repo=a crée le dépôt %s rename_repo=rebaptisé le dépôt de %[1]s à %[3]s -commit_repo=a soumis à %[2]s chez %[3]s +commit_repo=a soumis à %[3]s chez %[4]s create_issue=`a ouvert un problème %s#%[2]s` create_pull_request=`pull request créée le %s#%[2]s` comment_issue=`a commenté le problème %s#%[2]s` diff --git a/conf/locale/locale_it-IT.ini b/conf/locale/locale_it-IT.ini index 211693c4a..a3174a7f8 100755 --- a/conf/locale/locale_it-IT.ini +++ b/conf/locale/locale_it-IT.ini @@ -957,7 +957,7 @@ notices.delete_success=Avviso di sistema cancellato con successo. [action] create_repo=ha creato il repository %s rename_repo=renamed repository from %[1]s to %[3]s -commit_repo=ha pushato nel %[2]s in %[3]s +commit_repo=ha pushato nel %[3]s in %[4]s create_issue=`ha aperto il problema %s#%[2]s` create_pull_request=`creata pull request %s#%[2]s` comment_issue=`ha commentato il problema %s#%[2]s` diff --git a/conf/locale/locale_ja-JP.ini b/conf/locale/locale_ja-JP.ini index 3cc265afb..1bde5f038 100755 --- a/conf/locale/locale_ja-JP.ini +++ b/conf/locale/locale_ja-JP.ini @@ -957,7 +957,7 @@ notices.delete_success=システム通知が正常に削除されました。 [action] create_repo=リポジトリ %sを作成しました rename_repo=%[1]s から [3]s にリポジトリ名を変更した -commit_repo=%[3]s%[2]sにプッシュしました +commit_repo=%[4]s%[3]sにプッシュしました create_issue=`問題 %s#%[2]s を開きました` create_pull_request=`プルリクエスト %s[2]sを作成` comment_issue=`問題 %s#%[2]s のコメント` diff --git a/conf/locale/locale_lv-LV.ini b/conf/locale/locale_lv-LV.ini index 30be1c170..40745b226 100755 --- a/conf/locale/locale_lv-LV.ini +++ b/conf/locale/locale_lv-LV.ini @@ -957,7 +957,7 @@ notices.delete_success=Sistēmas paziņojums tika veiksmīgi izdzēsts. [action] create_repo=izveidoja repozitoriju %s rename_repo=pārsauca repozitoriju no %[1]s uz %[3]s -commit_repo=veica izmaiņu nosūtīšanu atzaram %[2]s repozitorijā %[3]s +commit_repo=veica izmaiņu nosūtīšanu atzaram %[3]s repozitorijā %[4]s create_issue=`reģistrēja problēmu %s#%[2]s` create_pull_request=`izveidoja izmaiņu pieprasījumu %s#%[2]s` comment_issue=`pievienoja komentāru problēmai %s#%[2]s` diff --git a/conf/locale/locale_nl-NL.ini b/conf/locale/locale_nl-NL.ini index e1bd6025d..efb6828af 100755 --- a/conf/locale/locale_nl-NL.ini +++ b/conf/locale/locale_nl-NL.ini @@ -957,7 +957,7 @@ notices.delete_success=Systeem bericht is met succes verwijderd. [action] create_repo=repositorie aangemaakt in %s rename_repo=renamed repository from %[1]s to %[3]s -commit_repo=push update naar %[2]s in %[3]s +commit_repo=push update naar %[3]s in %[4]s create_issue=`opende issue in %s#%[2]s` create_pull_request=`created pull request %s#%[2]s` comment_issue=`reactie op issue %s#%[2]s` diff --git a/conf/locale/locale_pl-PL.ini b/conf/locale/locale_pl-PL.ini index 934c493ba..380be25a2 100755 --- a/conf/locale/locale_pl-PL.ini +++ b/conf/locale/locale_pl-PL.ini @@ -957,7 +957,7 @@ notices.delete_success=Powiadomienia systemowe zostały usunięte pomyślnie. [action] create_repo=utworzono repozytorium %s rename_repo=nazwa repozytorium zmieniona z %[1]s na %[3]s -commit_repo=wypchnął do %[2]s w %[3]s +commit_repo=wypchnął do %[3]s w %[4]s create_issue=`zgłosił problem #%[2]s %[3]s` create_pull_request="stworzył pull request %s #%[2]s" comment_issue=`skomentował problem #%[2]s %[3]s` diff --git a/conf/locale/locale_pt-BR.ini b/conf/locale/locale_pt-BR.ini index ec806686c..f6d6aa966 100755 --- a/conf/locale/locale_pt-BR.ini +++ b/conf/locale/locale_pt-BR.ini @@ -957,7 +957,7 @@ notices.delete_success=Aviso do sistema foi deletado com sucesso. [action] create_repo=repositório criado %s rename_repo=renomeou o o repositório %[1]s para %[3]s -commit_repo=pushed para %[2]s em %[3]s +commit_repo=pushed para %[3]s em %[4]s create_issue='questão aberta %s#%[2]s' create_pull_request=`criou o pull request %s#%[2]s` comment_issue='comentou sobre a questão %s#%[2]s' diff --git a/conf/locale/locale_ru-RU.ini b/conf/locale/locale_ru-RU.ini index 31131cb63..4c02fcfef 100755 --- a/conf/locale/locale_ru-RU.ini +++ b/conf/locale/locale_ru-RU.ini @@ -957,7 +957,7 @@ notices.delete_success=Системное уведомление успешно [action] create_repo=создан репозиторий %s rename_repo=репозиторий переименован из %[1]sна %[3]s -commit_repo=запушил %[2]s в %[3]s +commit_repo=запушил %[3]s в %[4]s create_issue=`открытый вопрос %s#%[2]` create_pull_request=`созданный пулл-реквест %s#%[2]s` comment_issue=`прокомментировал(а) вопрос %s#%[2]s` diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index d6691ce04..422445e38 100755 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -957,7 +957,7 @@ notices.delete_success=系统提示删除成功! [action] create_repo=创建了仓库 %s rename_repo=重命名仓库 %[1]s%[3]s -commit_repo=推送了 %[2]s 分支的代码到 %[3]s +commit_repo=推送了 %[3]s 分支的代码到 %[4]s create_issue=`创建了工单 %s#%[2]s` create_pull_request=`创建了合并请求 %s#%[2]s` comment_issue=`评论了工单 %s#%[2]s` diff --git a/conf/locale/locale_zh-HK.ini b/conf/locale/locale_zh-HK.ini index 566dcc2cc..c039857a4 100755 --- a/conf/locale/locale_zh-HK.ini +++ b/conf/locale/locale_zh-HK.ini @@ -957,7 +957,7 @@ notices.delete_success=系統提示刪除成功! [action] create_repo=創建了倉庫 %s rename_repo=renamed repository from %[1]s to %[3]s -commit_repo=推送了 %[2]s 分支的代碼到 %[3]s +commit_repo=推送了 %[3]s 分支的代碼到 %[4]s create_issue=`創建了問題 %s#%[2]s` create_pull_request=`created pull request %s#%[2]s` comment_issue=`評論了問題 %s#%[2]s` diff --git a/modules/git/utils.go b/modules/git/utils.go index 78792aaf5..43a4da3d1 100644 --- a/modules/git/utils.go +++ b/modules/git/utils.go @@ -35,6 +35,10 @@ func parsePrettyFormatLog(repo *Repository, logByts []byte) (*list.List, error) } func RefEndName(refStr string) string { + if strings.HasPrefix(refStr, "refs/heads/") { + return strings.TrimPrefix(refStr, "refs/heads/") + } + index := strings.LastIndex(refStr, "/") if index != -1 { return refStr[index+1:] diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl index 70142f9a5..fff1e16f6 100644 --- a/templates/user/dashboard/feeds.tmpl +++ b/templates/user/dashboard/feeds.tmpl @@ -13,7 +13,8 @@ {{else if eq .GetOpType 2}} {{$.i18n.Tr "action.rename_repo" .GetContent .GetRepoLink .GetRepoPath | Str2html}} {{else if eq .GetOpType 5}} - {{$.i18n.Tr "action.commit_repo" .GetRepoLink .GetBranch .GetRepoPath | Str2html}} + {{ $branchLink := .GetBranch | EscapePound}} + {{$.i18n.Tr "action.commit_repo" .GetRepoLink $branchLink .GetBranch .GetRepoPath | Str2html}} {{else if eq .GetOpType 6}} {{ $index := index .GetIssueInfos 0}} {{$.i18n.Tr "action.create_issue" .GetRepoLink $index .GetRepoPath | Str2html}}