Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git-annex: add configuration setting [annex].ENABLED #18

Merged
merged 2 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmd/serv.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ func runServ(c *cli.Context) error {
verb := words[0]
repoPath := words[1]
if verb == gitAnnexShellVerb {
//if !setting.Annex.Enabled { // TODO: https://github.com/neuropoly/gitea/issues/8
if false {
if !setting.Annex.Enabled {
return fail("Unknown git command", "git-annex request over SSH denied, git-annex support is disabled")
}

Expand Down
4 changes: 4 additions & 0 deletions cmd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ func listen(m http.Handler, handleRedirector bool) error {
log.Info("LFS server enabled")
}

if setting.Annex.Enabled {
log.Info("git-annex enabled")
}

var err error
switch setting.Protocol {
case setting.HTTP:
Expand Down
9 changes: 9 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2360,6 +2360,15 @@ ROUTER = console
;; Where your lfs files reside, default is data/lfs.
;PATH = data/lfs

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;[annex]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Whether git-annex is enabled; defaults to false
;ENABLED = false
Comment on lines +2363 to +2370
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this bit of documentation through example files!


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; settings for packages, will override storage setting
Expand Down
21 changes: 21 additions & 0 deletions modules/setting/annex.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package setting

import (
"code.gitea.io/gitea/modules/log"
)

// LFS represents the configuration for Git LFS
kousu marked this conversation as resolved.
Show resolved Hide resolved
var Annex = struct {
Enabled bool `ini:"ENABLED"`
}{}

func newAnnex() {
sec := Cfg.Section("annex")
if err := sec.MapTo(&Annex); err != nil {
log.Fatal("Failed to map Annex settings: %v", err)
}
}
1 change: 1 addition & 0 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
API.SwaggerURL = u.String()

newGit()
newAnnex()

newMirror()

Expand Down
2 changes: 1 addition & 1 deletion routers/private/serv.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func ServCommand(ctx *context.PrivateContext) {
repo.IsPrivate ||
owner.Visibility.IsPrivate() ||
(user != nil && user.IsRestricted) || // user will be nil if the key is a deploykey
( /*setting.Annex.Enabled && */ len(verbs) > 0 && verbs[0] == "git-annex-shell") || // git-annex has its own permission enforcement, for which we expose results.UserMode
( setting.Annex.Enabled && len(verbs) > 0 && verbs[0] == "git-annex-shell") || // git-annex has its own permission enforcement, for which we expose results.UserMode
setting.Service.RequireSignInView) {
if key.Type == asymkey_model.KeyTypeDeploy {
results.UserMode = deployKey.Mode
Expand Down
9 changes: 3 additions & 6 deletions tests/integration/git_annex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ func doCreateRemoteAnnexRepository(t *testing.T, u *url.URL, ctx APITestContext,
Along the way, test that uploading, downloading, and deleting all work.
*/
func TestGitAnnexPermissions(t *testing.T) {
/*
// TODO: look into how LFS did this
if !setting.Annex.Enabled {
t.Skip()
}
*/
if !setting.Annex.Enabled {
t.Skip("Skipping since annex support is disabled.")
}

// Each case below is split so that 'clone' is done as
// the repo owner, but 'copy' as the user under test.
Expand Down
3 changes: 3 additions & 0 deletions tests/mysql.ini.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ SSH_TRUSTED_USER_CA_KEYS = ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCb4DC1dMFnJ6pXW
[lfs]
MINIO_BASE_PATH = lfs/

[annex]
ENABLED = true

[attachment]
MINIO_BASE_PATH = attachments/

Expand Down
3 changes: 3 additions & 0 deletions tests/mysql8.ini.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,8 @@ INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.h
[lfs]
PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mysql8/data/lfs

[annex]
ENABLED = true

[packages]
ENABLED = true
3 changes: 3 additions & 0 deletions tests/pgsql.ini.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,8 @@ INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.h
[lfs]
PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-pgsql/data/lfs

[annex]
ENABLED = true

[packages]
ENABLED = true
3 changes: 3 additions & 0 deletions tests/sqlite.ini.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,8 @@ JWT_SECRET = KZb_QLUd4fYVyxetjxC4eZkrBgWM2SndOOWDNtgUUko
[lfs]
PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-sqlite/data/lfs

[annex]
ENABLED = true

[packages]
ENABLED = true