From 8c6d7076b700a27c9c220f86a6e1e0e0b53b7fed Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sat, 11 Jan 2025 21:33:43 +0100 Subject: [PATCH 1/9] fix(cache): cache test triggered by non memory cache (#33220) Change SlowCacheThreshold to 30 milliseconds so it doesn't trigger on non memory cache Closes: https://github.com/go-gitea/gitea/issues/33190 Closes: https://github.com/go-gitea/gitea/issues/32657 --- modules/cache/cache.go | 9 +++++++-- modules/cache/cache_test.go | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/cache/cache.go b/modules/cache/cache.go index b5400b0bd6a14..f7828e3cae2df 100644 --- a/modules/cache/cache.go +++ b/modules/cache/cache.go @@ -37,10 +37,15 @@ func Init() error { } const ( - testCacheKey = "DefaultCache.TestKey" - SlowCacheThreshold = 100 * time.Microsecond + testCacheKey = "DefaultCache.TestKey" + // SlowCacheThreshold marks cache tests as slow + // set to 30ms per discussion: https://github.com/go-gitea/gitea/issues/33190 + // TODO: Replace with metrics histogram + SlowCacheThreshold = 30 * time.Millisecond ) +// Test performs delete, put and get operations on a predefined key +// returns func Test() (time.Duration, error) { if defaultCache == nil { return 0, fmt.Errorf("default cache not initialized") diff --git a/modules/cache/cache_test.go b/modules/cache/cache_test.go index d0352947a831a..5408020306b38 100644 --- a/modules/cache/cache_test.go +++ b/modules/cache/cache_test.go @@ -43,7 +43,8 @@ func TestTest(t *testing.T) { elapsed, err := Test() assert.NoError(t, err) // mem cache should take from 300ns up to 1ms on modern hardware ... - assert.Less(t, elapsed, time.Millisecond) + assert.Positive(t, elapsed) + assert.Less(t, elapsed, SlowCacheThreshold) } func TestGetCache(t *testing.T) { From fd7d393c67b69abee9e2934edbe7c571bab76a81 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 11 Jan 2025 16:05:33 -0800 Subject: [PATCH 2/9] Fix unpin hint on the pinned pull requests (#33207) --- models/issues/comment.go | 4 ++-- options/locale/locale_en-US.ini | 2 +- templates/repo/issue/card.tmpl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/models/issues/comment.go b/models/issues/comment.go index a7ec8f57fc412..a2487088205f3 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -112,8 +112,8 @@ const ( CommentTypePRScheduledToAutoMerge // 34 pr was scheduled to auto merge when checks succeed CommentTypePRUnScheduledToAutoMerge // 35 pr was un scheduled to auto merge when checks succeed - CommentTypePin // 36 pin Issue - CommentTypeUnpin // 37 unpin Issue + CommentTypePin // 36 pin Issue/PullRequest + CommentTypeUnpin // 37 unpin Issue/PullRequest CommentTypeChangeTimeEstimate // 38 Change time estimate ) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 140e2efe57111..9d240ac8978a9 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1652,7 +1652,7 @@ issues.attachment.open_tab = `Click to see "%s" in a new tab` issues.attachment.download = `Click to download "%s"` issues.subscribe = Subscribe issues.unsubscribe = Unsubscribe -issues.unpin_issue = Unpin Issue +issues.unpin = Unpin issues.max_pinned = "You can't pin more issues" issues.pin_comment = "pinned this %s" issues.unpin_comment = "unpinned this %s" diff --git a/templates/repo/issue/card.tmpl b/templates/repo/issue/card.tmpl index 2e19e86d7af30..c7bbe91885012 100644 --- a/templates/repo/issue/card.tmpl +++ b/templates/repo/issue/card.tmpl @@ -16,7 +16,7 @@ {{.Title | ctx.RenderUtils.RenderIssueSimpleTitle}} {{if and $.isPinnedIssueCard $.Page.IsRepoAdmin}} - + {{svg "octicon-x" 16}} {{end}} From a7e750414c41f41fb7783ab2e7266c5366d42424 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Sun, 12 Jan 2025 00:35:53 +0000 Subject: [PATCH 3/9] [skip ci] Updated translations via Crowdin --- options/locale/locale_cs-CZ.ini | 2 +- options/locale/locale_de-DE.ini | 2 +- options/locale/locale_el-GR.ini | 2 +- options/locale/locale_es-ES.ini | 2 +- options/locale/locale_fr-FR.ini | 2 +- options/locale/locale_ga-IE.ini | 15 ++++++++++++++- options/locale/locale_id-ID.ini | 1 + options/locale/locale_ja-JP.ini | 2 +- options/locale/locale_lv-LV.ini | 2 +- options/locale/locale_pt-BR.ini | 2 +- options/locale/locale_pt-PT.ini | 2 +- options/locale/locale_ru-RU.ini | 2 +- options/locale/locale_sk-SK.ini | 1 + options/locale/locale_tr-TR.ini | 2 +- options/locale/locale_zh-CN.ini | 2 +- options/locale/locale_zh-TW.ini | 2 +- 16 files changed, 29 insertions(+), 14 deletions(-) diff --git a/options/locale/locale_cs-CZ.ini b/options/locale/locale_cs-CZ.ini index 1d3bc7d577556..ad15d22dd2400 100644 --- a/options/locale/locale_cs-CZ.ini +++ b/options/locale/locale_cs-CZ.ini @@ -1651,7 +1651,7 @@ issues.attachment.open_tab=`Klikněte pro zobrazení „%s“ v nové záložce` issues.attachment.download=`Klikněte pro stažení „%s“` issues.subscribe=Odebírat issues.unsubscribe=Zrušit odběr -issues.unpin_issue=Odepnout úkol +issues.unpin=Odepnout issues.max_pinned=Nemůžete připnout další úkoly issues.pin_comment=připnuto %s issues.unpin_comment=odepnul/a tento %s diff --git a/options/locale/locale_de-DE.ini b/options/locale/locale_de-DE.ini index ce2c43cb568d0..e805f7fe0ac39 100644 --- a/options/locale/locale_de-DE.ini +++ b/options/locale/locale_de-DE.ini @@ -1646,7 +1646,7 @@ issues.attachment.open_tab=`Klicken, um „%s“ in einem neuen Tab zu öffnen` issues.attachment.download=`Klicken, um „%s“ herunterzuladen` issues.subscribe=Abonnieren issues.unsubscribe=Abbestellen -issues.unpin_issue=Issue abheften +issues.unpin=Loslösen issues.max_pinned=Du kannst keine weiteren Issues anheften issues.pin_comment=hat das %s angeheftet issues.unpin_comment=hat das %s abgeheftet diff --git a/options/locale/locale_el-GR.ini b/options/locale/locale_el-GR.ini index 31e57bbf97819..454e57eb128ab 100644 --- a/options/locale/locale_el-GR.ini +++ b/options/locale/locale_el-GR.ini @@ -1495,7 +1495,7 @@ issues.attachment.open_tab=`Κάντε κλικ για να δείτε το "%s" issues.attachment.download=`Κάντε κλικ για να λάβετε το "%s"` issues.subscribe=Εγγραφή issues.unsubscribe=Διαγραφή -issues.unpin_issue=Άφεση Ζητήματος +issues.unpin=Άφεση issues.max_pinned=Δεν μπορείτε να διατηρήσετε περισσότερα ζητήματα issues.pin_comment=διατήρησε αυτό %s issues.unpin_comment=άφησε αυτό %s diff --git a/options/locale/locale_es-ES.ini b/options/locale/locale_es-ES.ini index cdfe1fb2e5848..7dd8030d2b0c6 100644 --- a/options/locale/locale_es-ES.ini +++ b/options/locale/locale_es-ES.ini @@ -1485,7 +1485,7 @@ issues.attachment.open_tab='Haga clic para ver "%s" en una pestaña nueva' issues.attachment.download=`Haga clic para descargar "%s"` issues.subscribe=Suscribir issues.unsubscribe=Desuscribirse -issues.unpin_issue=Desanclar incidencia +issues.unpin=Desanclar issues.max_pinned=No puedes anclar más incidencias issues.pin_comment=anclado este %s issues.unpin_comment=desanclado este %s diff --git a/options/locale/locale_fr-FR.ini b/options/locale/locale_fr-FR.ini index becd8829fc76a..3615c6b24d23c 100644 --- a/options/locale/locale_fr-FR.ini +++ b/options/locale/locale_fr-FR.ini @@ -1651,7 +1651,7 @@ issues.attachment.open_tab=`Cliquez ici pour voir « %s » dans un nouvel ongl issues.attachment.download=`Cliquez pour télécharger « %s ».` issues.subscribe=S’abonner issues.unsubscribe=Se désabonner -issues.unpin_issue=Désépingler le ticket +issues.unpin=Désépingler issues.max_pinned=Vous ne pouvez pas épingler plus de tickets issues.pin_comment=a épinglé ça %s. issues.unpin_comment=a désépinglé ça %s. diff --git a/options/locale/locale_ga-IE.ini b/options/locale/locale_ga-IE.ini index cf6c76a9dbfc0..ef486b9e7a703 100644 --- a/options/locale/locale_ga-IE.ini +++ b/options/locale/locale_ga-IE.ini @@ -244,6 +244,7 @@ license_desc=Téigh go bhfaighidh doiciméadúchán roimh aon socruithe a athrú. require_db_desc=Éilíonn Gitea MySQL, PostgreSQL, MSSQL, SQLite3 nó TiDB (prótacal MySQL). @@ -1015,6 +1016,9 @@ new_repo_helper=Tá gach comhad tionscadail i stór, lena n-áirítear stair ath owner=Úinéir owner_helper=B'fhéidir nach dtaispeánfar roinnt eagraíochtaí sa anuas mar gheall ar theorainn uasta comhaireamh stórais. repo_name=Ainm Stórais +repo_name_profile_public_hint=Is stóras speisialta é .profile is féidir leat a úsáid chun README.md a chur le do phróifíl eagraíochta poiblí, le feiceáil ag aon duine. Cinntigh go bhfuil sé poiblí agus tosaigh é le README san eolaire próifíle le tosú. +repo_name_profile_private_hint=Is stóras speisialta é .profile-private is féidir leat a úsáid chun README.md a chur le do phróifíl bhall eagraíochta, nach féidir a fheiceáil ach ag baill eagraíochta. Cinntigh go bhfuil sé príobháideach agus tosaigh le README sa eolaire próifíle chun tús a chur leis. +repo_name_helper=Úsáideann ainmneacha maith stóras focail eochair gairide, áithnid agus uathúla. D'fhéadfaí stóras darbh ainm '.profile' nó '.profile-private' a úsáid chun README.md a chur leis an bpróifíl úsáideora/eagraíochta. repo_size=Méid an Stóras template=Teimpléad template_select=Roghnaigh teimpléad. @@ -1231,6 +1235,7 @@ create_new_repo_command=Stóras nua a chruthú ar an líne ordaithe push_exist_repo=Stóras atá ann cheana a bhrú ón líne ordaithe empty_message=Níl aon ábhar sa stóras seo. broken_message=Ní féidir na sonraí Git atá mar bhunús leis an stóras seo a léamh. Déan teagmháil le riarthóir an chás seo nó scrios an stóras seo. +no_branch=Níl aon bhrainsí ag an stóras seo. code=Cód code.desc=Rochtain ar chód foinse, comhaid, gealltanais agus brainsí. @@ -1646,7 +1651,7 @@ issues.attachment.open_tab=`Cliceáil chun "%s" a fheiceáil i gcluaisín nua` issues.attachment.download=`Cliceáil chun "%s" a íoslódáil issues.subscribe=Liostáil issues.unsubscribe=Díliostáil -issues.unpin_issue=Bain pionna an t-eagrán +issues.unpin=Díphoráil issues.max_pinned=Ní féidir leat níos mó saincheisteanna a phionadh issues.pin_comment=phionnáil an %s seo issues.unpin_comment=bain pionna an %s seo @@ -2622,6 +2627,9 @@ diff.image.overlay=Forleagan diff.has_escaped=Tá carachtair Unicode i bhfolach ag an líne seo diff.show_file_tree=Taispeáin crann comhad diff.hide_file_tree=Folaigh crann comhad +diff.submodule_added=Fomhodúl %[1]s curtha leis ag %[2]s +diff.submodule_deleted=Scriosadh fomhodúl %[1]s ó %[2]s +diff.submodule_updated=Nuashonraíodh fomhodúl %[1]s: %[2]s releases.desc=Rian leaganacha tionscadal agus íoslódálacha. release.releases=Eisiúintí @@ -2860,6 +2868,9 @@ teams.invite.title=Tugadh cuireadh duit dul isteach i bhfoireann %s/etc/apk/repositories: alpine.registry.key=Íoslódáil eochair RSA poiblí na clárlainne isteach san fhillteán /etc/apk/keys/ chun an síniú innéacs a fhíorú: alpine.registry.info=Roghnaigh $branch agus $repository ón liosta thíos. @@ -3755,6 +3767,7 @@ workflow.not_found=Níor aimsíodh sreabhadh oibre '%s'. workflow.run_success=Ritheann sreabhadh oibre '%s' go rathúil. workflow.from_ref=Úsáid sreabhadh oibre ó workflow.has_workflow_dispatch=Tá comhoibriú ag an gcur i bhfeidhm seo le himeacht workflow_dispatch. +workflow.has_no_workflow_dispatch=Níl aon truicear teagmhais workflow_dispatch ag sreabhadh oibre '%s'. need_approval_desc=Teastaíonn faomhadh chun sreafaí oibre a rith le haghaidh iarratas tarraingt forc. diff --git a/options/locale/locale_id-ID.ini b/options/locale/locale_id-ID.ini index 1fcf6d59b6c90..391691ebf5df6 100644 --- a/options/locale/locale_id-ID.ini +++ b/options/locale/locale_id-ID.ini @@ -818,6 +818,7 @@ issues.attachment.open_tab=`Klik untuk melihat "%s" di tab baru` issues.attachment.download=`Klik untuk mengunduh "%s"` issues.subscribe=Berlangganan issues.unsubscribe=Berhenti berlangganan +issues.unpin=Lepas sematan issues.delete=Hapus diff --git a/options/locale/locale_ja-JP.ini b/options/locale/locale_ja-JP.ini index 8ee9112c349f4..4fa61eb494e56 100644 --- a/options/locale/locale_ja-JP.ini +++ b/options/locale/locale_ja-JP.ini @@ -1641,7 +1641,7 @@ issues.attachment.open_tab=`クリックして新しいタブで "%s" を見る` issues.attachment.download=`クリックして "%s" をダウンロード` issues.subscribe=購読する issues.unsubscribe=購読を解除 -issues.unpin_issue=イシューのピン留めを解除 +issues.unpin=ピン留め解除 issues.max_pinned=これ以上イシューをピン留めできません issues.pin_comment=がピン留め %s issues.unpin_comment=がピン留めを解除 %s diff --git a/options/locale/locale_lv-LV.ini b/options/locale/locale_lv-LV.ini index 0dfc5683ecdbc..c90de9578b6e2 100644 --- a/options/locale/locale_lv-LV.ini +++ b/options/locale/locale_lv-LV.ini @@ -1501,7 +1501,7 @@ issues.attachment.open_tab=`Noklikšķiniet, lai apskatītos "%s" jaunā logā` issues.attachment.download=`Noklikšķiniet, lai lejupielādētu "%s"` issues.subscribe=Abonēt issues.unsubscribe=Atrakstīties -issues.unpin_issue=Atspraust problēmu +issues.unpin=Atspraust issues.max_pinned=Nevar piespraust vairāk problēmas issues.pin_comment=piesprauda šo %s issues.unpin_comment=atsprauda šo %s diff --git a/options/locale/locale_pt-BR.ini b/options/locale/locale_pt-BR.ini index f0c034a1331f3..f42de9287ed7b 100644 --- a/options/locale/locale_pt-BR.ini +++ b/options/locale/locale_pt-BR.ini @@ -1491,7 +1491,7 @@ issues.attachment.open_tab=`Clique para ver "%s" em uma nova aba` issues.attachment.download=`Clique para baixar "%s"` issues.subscribe=Inscrever-se issues.unsubscribe=Desinscrever -issues.unpin_issue=Desfixar issue +issues.unpin=Desfixar issues.max_pinned=Você não pode fixar mais issues issues.pin_comment=fixou isto %s issues.unpin_comment=desafixou isto %s diff --git a/options/locale/locale_pt-PT.ini b/options/locale/locale_pt-PT.ini index 824da09dda1ca..7b57e776d12d2 100644 --- a/options/locale/locale_pt-PT.ini +++ b/options/locale/locale_pt-PT.ini @@ -1651,7 +1651,7 @@ issues.attachment.open_tab=`Clique para ver "%s" num separador novo` issues.attachment.download=`Clique para descarregar "%s"` issues.subscribe=Subscrever issues.unsubscribe=Anular subscrição -issues.unpin_issue=Desafixar questão +issues.unpin=Desafixar issues.max_pinned=Já não pode fixar mais questões issues.pin_comment=fixou isto %s issues.unpin_comment=desafixou isto %s diff --git a/options/locale/locale_ru-RU.ini b/options/locale/locale_ru-RU.ini index 027a2cb19d3b8..9c6c706288b86 100644 --- a/options/locale/locale_ru-RU.ini +++ b/options/locale/locale_ru-RU.ini @@ -1471,7 +1471,7 @@ issues.attachment.open_tab=`Нажмите, чтобы увидеть «%s» в issues.attachment.download=`Нажмите, чтобы скачать «%s»` issues.subscribe=Подписаться issues.unsubscribe=Отказаться от подписки -issues.unpin_issue=Открепить задачу +issues.unpin=Открепить issues.max_pinned=Нельзя закрепить больше задач issues.pin_comment=закрепил(а) эту задачу %s issues.unpin_comment=открепил(а) эту задачу %s diff --git a/options/locale/locale_sk-SK.ini b/options/locale/locale_sk-SK.ini index 43b190098ff93..cd2f9157559d4 100644 --- a/options/locale/locale_sk-SK.ini +++ b/options/locale/locale_sk-SK.ini @@ -1068,6 +1068,7 @@ issues.dismiss_review=Zamietnuť revíziu issues.dismiss_review_warning=Naozaj chcete zrušiť túto revíziu? issues.cancel=Zrušiť issues.save=Uložiť +issues.unpin=Odopnúť diff --git a/options/locale/locale_tr-TR.ini b/options/locale/locale_tr-TR.ini index fb30ab3b67b6f..e939d9f04ea0a 100644 --- a/options/locale/locale_tr-TR.ini +++ b/options/locale/locale_tr-TR.ini @@ -1605,7 +1605,7 @@ issues.attachment.open_tab=`Yeni bir sekmede "%s" görmek için tıkla` issues.attachment.download=`"%s" indirmek için tıkla` issues.subscribe=Abone Ol issues.unsubscribe=Abonelikten Çık -issues.unpin_issue=Konuyu Sabitlemeden Kaldır +issues.unpin=Sabitlemeyi kaldır issues.max_pinned=Daha fazla konuyu sabitleyemezsiniz issues.pin_comment=%s sabitlendi issues.unpin_comment=%s sabitlenmesi kaldırıldı diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 5e4723a4cd848..564e9f9d8df1a 100644 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -1646,7 +1646,7 @@ issues.attachment.open_tab=`在新的标签页中查看 '%s'` issues.attachment.download=`点击下载 '%s'` issues.subscribe=订阅 issues.unsubscribe=取消订阅 -issues.unpin_issue=取消置顶 +issues.unpin=取消置顶 issues.max_pinned=您不能置顶更多工单 issues.pin_comment=于 %s 被置顶 issues.unpin_comment=于 %s 取消置顶 diff --git a/options/locale/locale_zh-TW.ini b/options/locale/locale_zh-TW.ini index 948b47bc9cb67..b4183aa70a07f 100644 --- a/options/locale/locale_zh-TW.ini +++ b/options/locale/locale_zh-TW.ini @@ -1640,7 +1640,7 @@ issues.attachment.open_tab=`在新分頁中查看「%s」` issues.attachment.download=`點擊下載「%s」` issues.subscribe=訂閱 issues.unsubscribe=取消訂閱 -issues.unpin_issue=取消固定問題 +issues.unpin=取消固定 issues.max_pinned=您不能固定更多問題 issues.pin_comment=固定於 %s issues.unpin_comment=取消固定於 %s From a068462ac08e3937ba829722d9a417763cb3763e Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 12 Jan 2025 11:39:46 +0800 Subject: [PATCH 4/9] Refactor context repository (#33202) --- modules/markup/asciicast/asciicast.go | 2 +- modules/markup/render.go | 4 +- routers/web/feed/branch.go | 2 +- routers/web/feed/file.go | 2 +- routers/web/repo/blame.go | 4 +- routers/web/repo/branch.go | 12 +-- routers/web/repo/cherry_pick.go | 4 +- routers/web/repo/commit.go | 2 +- routers/web/repo/editor.go | 8 +- routers/web/repo/middlewares.go | 12 +-- routers/web/repo/packages.go | 4 +- routers/web/repo/patch.go | 4 +- routers/web/repo/release.go | 6 +- routers/web/repo/render.go | 2 +- routers/web/repo/view.go | 4 +- routers/web/repo/view_file.go | 10 +-- routers/web/repo/view_home.go | 2 +- routers/web/repo/view_readme.go | 2 +- services/context/context_model.go | 20 ----- services/context/repo.go | 65 +++++++--------- templates/repo/blame.tmpl | 6 +- templates/repo/commits_table.tmpl | 2 +- templates/repo/editor/edit.tmpl | 2 +- templates/repo/header.tmpl | 2 +- templates/repo/home.tmpl | 6 +- templates/repo/settings/collaboration.tmpl | 90 +++++++++++----------- templates/repo/sub_menu.tmpl | 2 +- templates/repo/view_file.tmpl | 6 +- templates/repo/wiki/pages.tmpl | 2 +- 29 files changed, 125 insertions(+), 164 deletions(-) diff --git a/modules/markup/asciicast/asciicast.go b/modules/markup/asciicast/asciicast.go index 1d0d631650c1a..d86d61d7c4ca3 100644 --- a/modules/markup/asciicast/asciicast.go +++ b/modules/markup/asciicast/asciicast.go @@ -46,7 +46,7 @@ func (Renderer) Render(ctx *markup.RenderContext, _ io.Reader, output io.Writer) setting.AppSubURL, url.PathEscape(ctx.RenderOptions.Metas["user"]), url.PathEscape(ctx.RenderOptions.Metas["repo"]), - ctx.RenderOptions.Metas["BranchNameSubURL"], + ctx.RenderOptions.Metas["RefTypeNameSubURL"], url.PathEscape(ctx.RenderOptions.RelativePath), ) return ctx.RenderInternal.FormatWithSafeAttrs(output, `
`, playerClassName, playerSrcAttr, rawURL) diff --git a/modules/markup/render.go b/modules/markup/render.go index b239e59687b7b..37a2a86687d72 100644 --- a/modules/markup/render.go +++ b/modules/markup/render.go @@ -44,7 +44,7 @@ type RenderOptions struct { MarkupType string // user&repo, format&style®exp (for external issue pattern), teams&org (for mention) - // BranchNameSubURL (for iframe&asciicast) + // RefTypeNameSubURL (for iframe&asciicast) // markupAllowShortIssuePattern // markdownLineBreakStyle (comment, document) Metas map[string]string @@ -170,7 +170,7 @@ sandbox="allow-scripts" setting.AppSubURL, url.PathEscape(ctx.RenderOptions.Metas["user"]), url.PathEscape(ctx.RenderOptions.Metas["repo"]), - ctx.RenderOptions.Metas["BranchNameSubURL"], + ctx.RenderOptions.Metas["RefTypeNameSubURL"], url.PathEscape(ctx.RenderOptions.RelativePath), )) return err diff --git a/routers/web/feed/branch.go b/routers/web/feed/branch.go index 80ce2ad198bcd..6c4cc11ca0565 100644 --- a/routers/web/feed/branch.go +++ b/routers/web/feed/branch.go @@ -23,7 +23,7 @@ func ShowBranchFeed(ctx *context.Context, repo *repo.Repository, formatType stri } title := fmt.Sprintf("Latest commits for branch %s", ctx.Repo.BranchName) - link := &feeds.Link{Href: repo.HTMLURL() + "/" + ctx.Repo.BranchNameSubURL()} + link := &feeds.Link{Href: repo.HTMLURL() + "/" + ctx.Repo.RefTypeNameSubURL()} feed := &feeds.Feed{ Title: title, diff --git a/routers/web/feed/file.go b/routers/web/feed/file.go index 1ab768ff27fcb..973226435192f 100644 --- a/routers/web/feed/file.go +++ b/routers/web/feed/file.go @@ -35,7 +35,7 @@ func ShowFileFeed(ctx *context.Context, repo *repo.Repository, formatType string title := fmt.Sprintf("Latest commits for file %s", ctx.Repo.TreePath) - link := &feeds.Link{Href: repo.HTMLURL() + "/" + ctx.Repo.BranchNameSubURL() + "/" + util.PathEscapeSegments(ctx.Repo.TreePath)} + link := &feeds.Link{Href: repo.HTMLURL() + "/" + ctx.Repo.RefTypeNameSubURL() + "/" + util.PathEscapeSegments(ctx.Repo.TreePath)} feed := &feeds.Feed{ Title: title, diff --git a/routers/web/repo/blame.go b/routers/web/repo/blame.go index ad790875136c3..1022c5e6d6c26 100644 --- a/routers/web/repo/blame.go +++ b/routers/web/repo/blame.go @@ -46,9 +46,9 @@ func RefBlame(ctx *context.Context) { return } - branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() + branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL() treeLink := branchLink - rawLink := ctx.Repo.RepoLink + "/raw/" + ctx.Repo.BranchNameSubURL() + rawLink := ctx.Repo.RepoLink + "/raw/" + ctx.Repo.RefTypeNameSubURL() if len(ctx.Repo.TreePath) > 0 { treeLink += "/" + util.PathEscapeSegments(ctx.Repo.TreePath) diff --git a/routers/web/repo/branch.go b/routers/web/repo/branch.go index 5d58c64ec82e5..51d91b7d6a00a 100644 --- a/routers/web/repo/branch.go +++ b/routers/web/repo/branch.go @@ -185,7 +185,7 @@ func CreateBranch(ctx *context.Context) { if ctx.HasError() { ctx.Flash.Error(ctx.GetErrMsg()) - ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()) + ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()) return } @@ -205,25 +205,25 @@ func CreateBranch(ctx *context.Context) { if err != nil { if release_service.IsErrProtectedTagName(err) { ctx.Flash.Error(ctx.Tr("repo.release.tag_name_protected")) - ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()) + ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()) return } if release_service.IsErrTagAlreadyExists(err) { e := err.(release_service.ErrTagAlreadyExists) ctx.Flash.Error(ctx.Tr("repo.branch.tag_collision", e.TagName)) - ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()) + ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()) return } if git_model.IsErrBranchAlreadyExists(err) || git.IsErrPushOutOfDate(err) { ctx.Flash.Error(ctx.Tr("repo.branch.branch_already_exists", form.NewBranchName)) - ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()) + ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()) return } if git_model.IsErrBranchNameConflict(err) { e := err.(git_model.ErrBranchNameConflict) ctx.Flash.Error(ctx.Tr("repo.branch.branch_name_conflict", form.NewBranchName, e.BranchName)) - ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()) + ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()) return } if git.IsErrPushRejected(err) { @@ -242,7 +242,7 @@ func CreateBranch(ctx *context.Context) { } ctx.Flash.Error(flashError) } - ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()) + ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()) return } diff --git a/routers/web/repo/cherry_pick.go b/routers/web/repo/cherry_pick.go index 35f158df5258d..33d941c9d886c 100644 --- a/routers/web/repo/cherry_pick.go +++ b/routers/web/repo/cherry_pick.go @@ -57,7 +57,7 @@ func CherryPick(ctx *context.Context) { ctx.Data["new_branch_name"] = GetUniquePatchBranchName(ctx) ctx.Data["last_commit"] = ctx.Repo.CommitID ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",") - ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() + ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL() ctx.HTML(200, tplCherryPick) } @@ -85,7 +85,7 @@ func CherryPickPost(ctx *context.Context) { ctx.Data["new_branch_name"] = form.NewBranchName ctx.Data["last_commit"] = ctx.Repo.CommitID ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",") - ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() + ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL() if ctx.HasError() { ctx.HTML(200, tplCherryPick) diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index 3655233312c34..638b5e680aaa4 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -191,7 +191,7 @@ func SearchCommits(ctx *context.Context) { query := ctx.FormTrim("q") if len(query) == 0 { - ctx.Redirect(ctx.Repo.RepoLink + "/commits/" + ctx.Repo.BranchNameSubURL()) + ctx.Redirect(ctx.Repo.RepoLink + "/commits/" + ctx.Repo.RefTypeNameSubURL()) return } diff --git a/routers/web/repo/editor.go b/routers/web/repo/editor.go index 5fbdeee27e3a5..85f407ab8d795 100644 --- a/routers/web/repo/editor.go +++ b/routers/web/repo/editor.go @@ -180,7 +180,7 @@ func editFile(ctx *context.Context, isNewFile bool) { ctx.Data["TreeNames"] = treeNames ctx.Data["TreePaths"] = treePaths - ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() + ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL() ctx.Data["commit_summary"] = "" ctx.Data["commit_message"] = "" if canCommit { @@ -428,7 +428,7 @@ func DiffPreviewPost(ctx *context.Context) { // DeleteFile render delete file page func DeleteFile(ctx *context.Context) { ctx.Data["PageIsDelete"] = true - ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() + ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL() treePath := cleanUploadFileName(ctx.Repo.TreePath) if treePath != ctx.Repo.TreePath { @@ -462,7 +462,7 @@ func DeleteFilePost(ctx *context.Context) { } ctx.Data["PageIsDelete"] = true - ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() + ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL() ctx.Data["TreePath"] = ctx.Repo.TreePath ctx.Data["commit_summary"] = form.CommitSummary ctx.Data["commit_message"] = form.CommitMessage @@ -604,7 +604,7 @@ func UploadFile(ctx *context.Context) { ctx.Data["TreeNames"] = treeNames ctx.Data["TreePaths"] = treePaths - ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() + ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL() ctx.Data["commit_summary"] = "" ctx.Data["commit_message"] = "" if canCommit { diff --git a/routers/web/repo/middlewares.go b/routers/web/repo/middlewares.go index 420931c5fb729..7518e6feae916 100644 --- a/routers/web/repo/middlewares.go +++ b/routers/web/repo/middlewares.go @@ -4,12 +4,9 @@ package repo import ( - "fmt" "strconv" - system_model "code.gitea.io/gitea/models/system" user_model "code.gitea.io/gitea/models/user" - "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/optional" "code.gitea.io/gitea/services/context" user_service "code.gitea.io/gitea/services/user" @@ -22,12 +19,9 @@ func SetEditorconfigIfExists(ctx *context.Context) { } ec, _, err := ctx.Repo.GetEditorconfig() - - if err != nil && !git.IsErrNotExist(err) { - description := fmt.Sprintf("Error while getting .editorconfig file: %v", err) - if err := system_model.CreateRepositoryNotice(description); err != nil { - ctx.ServerError("ErrCreatingReporitoryNotice", err) - } + if err != nil { + // it used to check `!git.IsErrNotExist(err)` and create a system notice, but it is quite annoying and useless + // because network errors also happen frequently, so we just ignore it return } diff --git a/routers/web/repo/packages.go b/routers/web/repo/packages.go index 5dcfd0454c802..65a340a799700 100644 --- a/routers/web/repo/packages.go +++ b/routers/web/repo/packages.go @@ -62,9 +62,7 @@ func Packages(ctx *context.Context) { ctx.Data["PackageType"] = packageType ctx.Data["AvailableTypes"] = packages.TypeList ctx.Data["HasPackages"] = hasPackages - if ctx.Repo != nil { - ctx.Data["CanWritePackages"] = ctx.IsUserRepoWriter([]unit.Type{unit.TypePackages}) || ctx.IsUserSiteAdmin() - } + ctx.Data["CanWritePackages"] = ctx.Repo.CanWrite(unit.TypePackages) || ctx.IsUserSiteAdmin() ctx.Data["PackageDescriptors"] = pds ctx.Data["Total"] = total ctx.Data["RepositoryAccessMap"] = map[int64]bool{ctx.Repo.Repository.ID: true} // There is only the current repository diff --git a/routers/web/repo/patch.go b/routers/web/repo/patch.go index 1807cf31a1280..4d47a705d6e94 100644 --- a/routers/web/repo/patch.go +++ b/routers/web/repo/patch.go @@ -37,7 +37,7 @@ func NewDiffPatch(ctx *context.Context) { ctx.Data["new_branch_name"] = GetUniquePatchBranchName(ctx) ctx.Data["last_commit"] = ctx.Repo.CommitID ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",") - ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() + ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL() ctx.HTML(200, tplPatchFile) } @@ -52,7 +52,7 @@ func NewDiffPatchPost(ctx *context.Context) { branchName = form.NewBranchName } ctx.Data["PageIsPatch"] = true - ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() + ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL() ctx.Data["FileContent"] = form.Content ctx.Data["commit_summary"] = form.CommitSummary ctx.Data["commit_message"] = form.CommitMessage diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index 5b099fe8d4fa3..53655703fcb9f 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -435,19 +435,19 @@ func NewReleasePost(ctx *context.Context) { if release_service.IsErrTagAlreadyExists(err) { e := err.(release_service.ErrTagAlreadyExists) ctx.Flash.Error(ctx.Tr("repo.branch.tag_collision", e.TagName)) - ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()) + ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()) return } if release_service.IsErrInvalidTagName(err) { ctx.Flash.Error(ctx.Tr("repo.release.tag_name_invalid")) - ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()) + ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()) return } if release_service.IsErrProtectedTagName(err) { ctx.Flash.Error(ctx.Tr("repo.release.tag_name_protected")) - ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()) + ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()) return } diff --git a/routers/web/repo/render.go b/routers/web/repo/render.go index 856425ae355c5..069bf6f6bfa4c 100644 --- a/routers/web/repo/render.go +++ b/routers/web/repo/render.go @@ -58,7 +58,7 @@ func RenderFile(ctx *context.Context) { } rctx := renderhelper.NewRenderContextRepoFile(ctx, ctx.Repo.Repository, renderhelper.RepoFileOptions{ - CurrentRefPath: ctx.Repo.BranchNameSubURL(), + CurrentRefPath: ctx.Repo.RefTypeNameSubURL(), CurrentTreePath: path.Dir(ctx.Repo.TreePath), }).WithRelativePath(ctx.Repo.TreePath).WithInStandalonePage(true) diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 9fe2b58ebc66d..05ecf2ab794b3 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -243,7 +243,7 @@ func LastCommit(ctx *context.Context) { ctx.Data["ParentPath"] = "/" + paths[len(paths)-2] } } - branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() + branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL() ctx.Data["BranchLink"] = branchLink ctx.HTML(http.StatusOK, tplRepoViewList) @@ -301,7 +301,7 @@ func renderDirectoryFiles(ctx *context.Context, timeout time.Duration) git.Entri return nil } - branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() + branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL() treeLink := branchLink if len(ctx.Repo.TreePath) > 0 { diff --git a/routers/web/repo/view_file.go b/routers/web/repo/view_file.go index 17c2821824339..f4be4783fb739 100644 --- a/routers/web/repo/view_file.go +++ b/routers/web/repo/view_file.go @@ -45,7 +45,7 @@ func prepareToRenderFile(ctx *context.Context, entry *git.TreeEntry) { ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+path.Base(ctx.Repo.TreePath), ctx.Repo.RefName) ctx.Data["FileIsSymlink"] = entry.IsLink() ctx.Data["FileName"] = blob.Name() - ctx.Data["RawFileLink"] = ctx.Repo.RepoLink + "/raw/" + ctx.Repo.BranchNameSubURL() + "/" + util.PathEscapeSegments(ctx.Repo.TreePath) + ctx.Data["RawFileLink"] = ctx.Repo.RepoLink + "/raw/" + ctx.Repo.RefTypeNameSubURL() + "/" + util.PathEscapeSegments(ctx.Repo.TreePath) commit, err := ctx.Repo.Commit.GetCommitByPath(ctx.Repo.TreePath) if err != nil { @@ -92,7 +92,7 @@ func prepareToRenderFile(ctx *context.Context, entry *git.TreeEntry) { isDisplayingRendered := !isDisplayingSource if fInfo.isLFSFile { - ctx.Data["RawFileLink"] = ctx.Repo.RepoLink + "/media/" + ctx.Repo.BranchNameSubURL() + "/" + util.PathEscapeSegments(ctx.Repo.TreePath) + ctx.Data["RawFileLink"] = ctx.Repo.RepoLink + "/media/" + ctx.Repo.RefTypeNameSubURL() + "/" + util.PathEscapeSegments(ctx.Repo.TreePath) } isRepresentableAsText := fInfo.st.IsRepresentableAsText() @@ -170,9 +170,9 @@ func prepareToRenderFile(ctx *context.Context, entry *git.TreeEntry) { ctx.Data["IsMarkup"] = true ctx.Data["MarkupType"] = markupType metas := ctx.Repo.Repository.ComposeDocumentMetas(ctx) - metas["BranchNameSubURL"] = ctx.Repo.BranchNameSubURL() + metas["RefTypeNameSubURL"] = ctx.Repo.RefTypeNameSubURL() rctx := renderhelper.NewRenderContextRepoFile(ctx, ctx.Repo.Repository, renderhelper.RepoFileOptions{ - CurrentRefPath: ctx.Repo.BranchNameSubURL(), + CurrentRefPath: ctx.Repo.RefTypeNameSubURL(), CurrentTreePath: path.Dir(ctx.Repo.TreePath), }). WithMarkupType(markupType). @@ -262,7 +262,7 @@ func prepareToRenderFile(ctx *context.Context, entry *git.TreeEntry) { ctx.Data["MarkupType"] = markupType rctx := renderhelper.NewRenderContextRepoFile(ctx, ctx.Repo.Repository, renderhelper.RepoFileOptions{ - CurrentRefPath: ctx.Repo.BranchNameSubURL(), + CurrentRefPath: ctx.Repo.RefTypeNameSubURL(), CurrentTreePath: path.Dir(ctx.Repo.TreePath), }). WithMarkupType(markupType). diff --git a/routers/web/repo/view_home.go b/routers/web/repo/view_home.go index 8c9f54656b0c0..7aa8a72430485 100644 --- a/routers/web/repo/view_home.go +++ b/routers/web/repo/view_home.go @@ -346,7 +346,7 @@ func Home(ctx *context.Context) { // prepare the tree path var treeNames, paths []string - branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() + branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL() treeLink := branchLink if ctx.Repo.TreePath != "" { treeLink += "/" + util.PathEscapeSegments(ctx.Repo.TreePath) diff --git a/routers/web/repo/view_readme.go b/routers/web/repo/view_readme.go index 5bd39de96315d..48befe47f8e0e 100644 --- a/routers/web/repo/view_readme.go +++ b/routers/web/repo/view_readme.go @@ -189,7 +189,7 @@ func prepareToRenderReadmeFile(ctx *context.Context, subfolder string, readmeFil ctx.Data["MarkupType"] = markupType rctx := renderhelper.NewRenderContextRepoFile(ctx, ctx.Repo.Repository, renderhelper.RepoFileOptions{ - CurrentRefPath: ctx.Repo.BranchNameSubURL(), + CurrentRefPath: ctx.Repo.RefTypeNameSubURL(), CurrentTreePath: path.Join(ctx.Repo.TreePath, subfolder), }). WithMarkupType(markupType). diff --git a/services/context/context_model.go b/services/context/context_model.go index 4f70aac51695a..3a1776102ff8e 100644 --- a/services/context/context_model.go +++ b/services/context/context_model.go @@ -3,27 +3,7 @@ package context -import ( - "code.gitea.io/gitea/models/unit" -) - // IsUserSiteAdmin returns true if current user is a site admin func (ctx *Context) IsUserSiteAdmin() bool { return ctx.IsSigned && ctx.Doer.IsAdmin } - -// IsUserRepoAdmin returns true if current user is admin in current repo -func (ctx *Context) IsUserRepoAdmin() bool { - return ctx.Repo.IsAdmin() -} - -// IsUserRepoWriter returns true if current user has write privilege in current repo -func (ctx *Context) IsUserRepoWriter(unitTypes []unit.Type) bool { - for _, unitType := range unitTypes { - if ctx.Repo.CanWrite(unitType) { - return true - } - } - - return false -} diff --git a/services/context/repo.go b/services/context/repo.go index 94b2972c2bd3b..121910235f1e8 100644 --- a/services/context/repo.go +++ b/services/context/repo.go @@ -46,22 +46,27 @@ type PullRequest struct { // Repository contains information to operate a repository type Repository struct { access_model.Permission - IsWatching bool + + Repository *repo_model.Repository + Owner *user_model.User + + RepoLink string + GitRepo *git.Repository + + // these fields indicate the current ref type, for example: ".../src/branch/master" means IsViewBranch=true IsViewBranch bool IsViewTag bool IsViewCommit bool - Repository *repo_model.Repository - Owner *user_model.User - Commit *git.Commit - Tag *git.Tag - GitRepo *git.Repository - RefName string - BranchName string - TagName string - TreePath string - CommitID string - RepoLink string - CloneLink repo_model.CloneLink + + RefName string + BranchName string + TagName string + TreePath string + + // Commit it is always set to the commit for the branch or tag + Commit *git.Commit + CommitID string + CommitsCount int64 PullRequest *PullRequest @@ -149,7 +154,7 @@ func (r *Repository) CanCommitToBranch(ctx context.Context, doer *user_model.Use }, err } -// CanUseTimetracker returns whether or not a user can use the timetracker. +// CanUseTimetracker returns whether a user can use the timetracker. func (r *Repository) CanUseTimetracker(ctx context.Context, issue *issues_model.Issue, user *user_model.User) bool { // Checking for following: // 1. Is timetracker enabled @@ -199,8 +204,12 @@ func (r *Repository) GetCommitGraphsCount(ctx context.Context, hidePRRefs bool, }) } -// BranchNameSubURL sub-URL for the BranchName field -func (r *Repository) BranchNameSubURL() string { +// RefTypeNameSubURL makes a sub-url for the current ref (branch/tag/commit) field, for example: +// * "branch/master" +// * "tag/v1.0.0" +// * "commit/123456" +// It is usually used to construct a link like ".../src/{{RefTypeNameSubURL}}/{{PathEscapeSegments TreePath}}" +func (r *Repository) RefTypeNameSubURL() string { switch { case r.IsViewBranch: return "branch/" + util.PathEscapeSegments(r.BranchName) @@ -213,21 +222,6 @@ func (r *Repository) BranchNameSubURL() string { return "" } -// FileExists returns true if a file exists in the given repo branch -func (r *Repository) FileExists(path, branch string) (bool, error) { - if branch == "" { - branch = r.Repository.DefaultBranch - } - commit, err := r.GitRepo.GetBranchCommit(branch) - if err != nil { - return false, err - } - if _, err := commit.GetTreeEntryByPath(path); err != nil { - return false, err - } - return true, nil -} - // GetEditorconfig returns the .editorconfig definition if found in the // HEAD of the default repo branch. func (r *Repository) GetEditorconfig(optCommit ...*git.Commit) (cfg *editorconfig.Editorconfig, warning, err error) { @@ -450,7 +444,6 @@ func RepoAssignment(ctx *Context) { ctx.Repo.Owner = owner ctx.ContextUser = owner ctx.Data["ContextUser"] = ctx.ContextUser - ctx.Data["Username"] = ctx.Repo.Owner.Name // redirect link to wiki if strings.HasSuffix(repoName, ".wiki") { @@ -502,7 +495,6 @@ func RepoAssignment(ctx *Context) { ctx.Repo.RepoLink = repo.Link() ctx.Data["RepoLink"] = ctx.Repo.RepoLink - ctx.Data["RepoRelPath"] = ctx.Repo.Owner.Name + "/" + ctx.Repo.Repository.Name if setting.Other.EnableFeed { ctx.Data["EnableFeed"] = true @@ -537,9 +529,6 @@ func RepoAssignment(ctx *Context) { ctx.Data["Title"] = owner.Name + "/" + repo.Name ctx.Data["Repository"] = repo ctx.Data["Owner"] = ctx.Repo.Repository.Owner - ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner() - ctx.Data["IsRepositoryAdmin"] = ctx.Repo.IsAdmin() - ctx.Data["RepoOwnerIsOrganization"] = repo.Owner.IsOrganization() ctx.Data["CanWriteCode"] = ctx.Repo.CanWrite(unit_model.TypeCode) ctx.Data["CanWriteIssues"] = ctx.Repo.CanWrite(unit_model.TypeIssues) ctx.Data["CanWritePulls"] = ctx.Repo.CanWrite(unit_model.TypePullRequests) @@ -979,7 +968,7 @@ func RepoRefByType(detectRefType RepoRefType, opts ...RepoRefByTypeOptions) func redirect := path.Join( ctx.Repo.RepoLink, util.PathEscapeSegments(prefix), - ctx.Repo.BranchNameSubURL(), + ctx.Repo.RefTypeNameSubURL(), util.PathEscapeSegments(ctx.Repo.TreePath)) ctx.Redirect(redirect) return @@ -988,7 +977,7 @@ func RepoRefByType(detectRefType RepoRefType, opts ...RepoRefByTypeOptions) func ctx.Data["BranchName"] = ctx.Repo.BranchName ctx.Data["RefName"] = ctx.Repo.RefName - ctx.Data["BranchNameSubURL"] = ctx.Repo.BranchNameSubURL() + ctx.Data["RefTypeNameSubURL"] = ctx.Repo.RefTypeNameSubURL() ctx.Data["TagName"] = ctx.Repo.TagName ctx.Data["CommitID"] = ctx.Repo.CommitID ctx.Data["TreePath"] = ctx.Repo.TreePath diff --git a/templates/repo/blame.tmpl b/templates/repo/blame.tmpl index 62d1bbf2ba7c4..f8bd22074f490 100644 --- a/templates/repo/blame.tmpl +++ b/templates/repo/blame.tmpl @@ -1,5 +1,5 @@ {{if or .UsesIgnoreRevs .FaultyIgnoreRevsFile}} - {{$revsFileLink := URLJoin .RepoLink "src" .BranchNameSubURL "/.git-blame-ignore-revs"}} + {{$revsFileLink := URLJoin .RepoLink "src" .RefTypeNameSubURL "/.git-blame-ignore-revs"}} {{if .UsesIgnoreRevs}}

{{ctx.Locale.Tr "repo.blame.ignore_revs" $revsFileLink "?bypass-blame-ignore=true"}}

@@ -21,8 +21,8 @@ {{if not .IsViewCommit}} {{ctx.Locale.Tr "repo.file_permalink"}} {{end}} - {{ctx.Locale.Tr "repo.normal_view"}} - {{ctx.Locale.Tr "repo.file_history"}} + {{ctx.Locale.Tr "repo.normal_view"}} + {{ctx.Locale.Tr "repo.file_history"}}
diff --git a/templates/repo/commits_table.tmpl b/templates/repo/commits_table.tmpl index 91fc1c2faede2..a0c5eacdd4b00 100644 --- a/templates/repo/commits_table.tmpl +++ b/templates/repo/commits_table.tmpl @@ -19,7 +19,7 @@ {{if .PageIsCommits}}
-
+
{{template "shared/search/input" dict "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.commit_kind")}} {{template "repo/commits_search_dropdown" .}} diff --git a/templates/repo/editor/edit.tmpl b/templates/repo/editor/edit.tmpl index 204a42697078f..577a2be9ad38e 100644 --- a/templates/repo/editor/edit.tmpl +++ b/templates/repo/editor/edit.tmpl @@ -32,7 +32,7 @@