summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorGergely Nagy <forgejo@gergo.csillger.hu>2023-12-31 16:24:05 +0100
committerEarl Warren <contact@earl-warren.org>2024-02-05 16:09:42 +0100
commit1d8bca07f3bd6017e0b84c21cb66a9271c8693f5 (patch)
tree0442661ae626583b86adc0f49549330b66cd5184 /modules
parent[GITEA] Fix NPE in `ToPullReviewList` (diff)
downloadforgejo-1d8bca07f3bd6017e0b84c21cb66a9271c8693f5.tar.xz
forgejo-1d8bca07f3bd6017e0b84c21cb66a9271c8693f5.zip
[GITEA] Configurable clone methods
Adds `[repository].DOWNLOAD_OR_CLONE_METHODS` (defaulting to "download-zip,download-targz,download-bundle,vscode-clone"), which lets an instance administrator override the additional clone methods displayed on the repository home view. This is purely display-only, the clone methods not listed here are still available, unless disabled elsewhere. They're just not displayed. Fixes #710. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu> (cherry picked from commit 2aadcf4946e48ee43800568fe705d00a062c42bf) (cherry picked from commit 42ac34fbf9105eed27ee687b305a85515270f0cc) (cherry picked from commit bd231b02450212aca6be775663c3d24ddf19f990) (cherry picked from commit 3d3366dbbee37621fc665e557a4a87bf08104375) (cherry picked from commit 0157fb9b88fd50832c07b06c11c8dba6e059a465) (cherry picked from commit bee88f6a8309c6f9aeba1522383d77f08e5a4d2d)
Diffstat (limited to 'modules')
-rw-r--r--modules/setting/repository.go11
-rw-r--r--modules/web/middleware/data.go1
2 files changed, 12 insertions, 0 deletions
diff --git a/modules/setting/repository.go b/modules/setting/repository.go
index a722ea2a0f..b6b0b50504 100644
--- a/modules/setting/repository.go
+++ b/modules/setting/repository.go
@@ -7,6 +7,7 @@ import (
"os/exec"
"path"
"path/filepath"
+ "slices"
"strings"
"code.gitea.io/gitea/modules/log"
@@ -19,6 +20,8 @@ const (
RepoCreatingPublic = "public"
)
+var RecognisedRepositoryDownloadOrCloneMethods = []string{"download-zip", "download-targz", "download-bundle", "vscode-clone", "vscodium-clone", "cite"}
+
// ItemsPerPage maximum items per page in forks, watchers and stars of a repo
const ItemsPerPage = 40
@@ -43,6 +46,7 @@ var (
DisabledRepoUnits []string
DefaultRepoUnits []string
DefaultForkRepoUnits []string
+ DownloadOrCloneMethods []string
PrefixArchiveFiles bool
DisableMigrations bool
DisableStars bool `ini:"DISABLE_STARS"`
@@ -161,6 +165,7 @@ var (
DisabledRepoUnits: []string{},
DefaultRepoUnits: []string{},
DefaultForkRepoUnits: []string{},
+ DownloadOrCloneMethods: []string{"download-zip", "download-targz", "download-bundle", "vscode-clone"},
PrefixArchiveFiles: true,
DisableMigrations: false,
DisableStars: false,
@@ -361,4 +366,10 @@ func loadRepositoryFrom(rootCfg ConfigProvider) {
if err := loadRepoArchiveFrom(rootCfg); err != nil {
log.Fatal("loadRepoArchiveFrom: %v", err)
}
+
+ for _, method := range Repository.DownloadOrCloneMethods {
+ if !slices.Contains(RecognisedRepositoryDownloadOrCloneMethods, method) {
+ log.Error("Unrecognised repository download or clone method: %s", method)
+ }
+ }
}
diff --git a/modules/web/middleware/data.go b/modules/web/middleware/data.go
index 08d83f94be..c1d1af8528 100644
--- a/modules/web/middleware/data.go
+++ b/modules/web/middleware/data.go
@@ -53,6 +53,7 @@ func CommonTemplateContextData() ContextData {
"ShowMilestonesDashboardPage": setting.Service.ShowMilestonesDashboardPage,
"ShowFooterVersion": setting.Other.ShowFooterVersion,
"DisableDownloadSourceArchives": setting.Repository.DisableDownloadSourceArchives,
+ "DownloadOrCloneMethods": setting.Repository.DownloadOrCloneMethods,
"EnableSwagger": setting.API.EnableSwagger,
"EnableOpenIDSignIn": setting.Service.EnableOpenIDSignIn,