Skip to content

Commit 571c912

Browse files
kousumguaypaq
authored andcommitted
git-annex: add configuration setting [annex].ENABLED (#18)
* git-annex: add configuration setting [annex].ENABLED Fixes #8 Co-authored-by: Mathieu Guay-Paquet <[email protected]>
1 parent ace51f8 commit 571c912

File tree

11 files changed

+52
-9
lines changed

11 files changed

+52
-9
lines changed

cmd/serv.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ func runServ(c *cli.Context) error {
183183
verb := words[0]
184184
repoPath := words[1]
185185
if verb == gitAnnexShellVerb {
186-
//if !setting.Annex.Enabled { // TODO: https://github.com/neuropoly/gitea/issues/8
187-
if false {
186+
if !setting.Annex.Enabled {
188187
return fail("Unknown git command", "git-annex request over SSH denied, git-annex support is disabled")
189188
}
190189

cmd/web.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ func listen(m http.Handler, handleRedirector bool) error {
227227
log.Info("LFS server enabled")
228228
}
229229

230+
if setting.Annex.Enabled {
231+
log.Info("git-annex enabled")
232+
}
233+
230234
var err error
231235
switch setting.Protocol {
232236
case setting.HTTP:

custom/conf/app.example.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,6 +2360,15 @@ ROUTER = console
23602360
;; Where your lfs files reside, default is data/lfs.
23612361
;PATH = data/lfs
23622362

2363+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2364+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2365+
;[annex]
2366+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2367+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2368+
;;
2369+
;; Whether git-annex is enabled; defaults to false
2370+
;ENABLED = false
2371+
23632372
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23642373
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23652374
;; settings for packages, will override storage setting

modules/setting/annex.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2019 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package setting
6+
7+
import (
8+
"code.gitea.io/gitea/modules/log"
9+
)
10+
11+
// Annex represents the configuration for git-annex
12+
var Annex = struct {
13+
Enabled bool `ini:"ENABLED"`
14+
}{}
15+
16+
func newAnnex() {
17+
sec := Cfg.Section("annex")
18+
if err := sec.MapTo(&Annex); err != nil {
19+
log.Fatal("Failed to map Annex settings: %v", err)
20+
}
21+
}

modules/setting/setting.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
10701070
API.SwaggerURL = u.String()
10711071

10721072
newGit()
1073+
newAnnex()
10731074

10741075
newMirror()
10751076

routers/private/serv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ func ServCommand(ctx *context.PrivateContext) {
307307
repo.IsPrivate ||
308308
owner.Visibility.IsPrivate() ||
309309
(user != nil && user.IsRestricted) || // user will be nil if the key is a deploykey
310-
( /*setting.Annex.Enabled && */ len(verbs) > 0 && verbs[0] == "git-annex-shell") || // git-annex has its own permission enforcement, for which we expose results.UserMode
310+
( setting.Annex.Enabled && len(verbs) > 0 && verbs[0] == "git-annex-shell") || // git-annex has its own permission enforcement, for which we expose results.UserMode
311311
setting.Service.RequireSignInView) {
312312
if key.Type == asymkey_model.KeyTypeDeploy {
313313
results.UserMode = deployKey.Mode

tests/integration/git_annex_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,9 @@ func doCreateRemoteAnnexRepository(t *testing.T, u *url.URL, ctx APITestContext,
5454
Along the way, test that uploading, downloading, and deleting all work.
5555
*/
5656
func TestGitAnnexPermissions(t *testing.T) {
57-
/*
58-
// TODO: look into how LFS did this
59-
if !setting.Annex.Enabled {
60-
t.Skip()
61-
}
62-
*/
57+
if !setting.Annex.Enabled {
58+
t.Skip("Skipping since annex support is disabled.")
59+
}
6360

6461
// Each case below is split so that 'clone' is done as
6562
// the repo owner, but 'copy' as the user under test.

tests/mysql.ini.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ SSH_TRUSTED_USER_CA_KEYS = ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCb4DC1dMFnJ6pXW
5858
[lfs]
5959
MINIO_BASE_PATH = lfs/
6060

61+
[annex]
62+
ENABLED = true
63+
6164
[attachment]
6265
MINIO_BASE_PATH = attachments/
6366

tests/mysql8.ini.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,8 @@ INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.h
103103
[lfs]
104104
PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mysql8/data/lfs
105105

106+
[annex]
107+
ENABLED = true
108+
106109
[packages]
107110
ENABLED = true

tests/pgsql.ini.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,8 @@ INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.h
107107
[lfs]
108108
PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-pgsql/data/lfs
109109

110+
[annex]
111+
ENABLED = true
112+
110113
[packages]
111114
ENABLED = true

0 commit comments

Comments
 (0)