aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorMax Resnick <max@ofmax.li>2023-01-29 07:16:25 -0800
committerMax Resnick <max@ofmax.li>2023-01-29 07:16:25 -0800
commit45a8dfd3ba345eebe268fc92d31612e14907fb01 (patch)
treea6a0eff5eaec8f252da23477d73d742d8a867ada /internal
parent0ac7b93645b169c55f9c50423fab9d4a402e9918 (diff)
downloadgo-git-server-45a8dfd3ba345eebe268fc92d31612e14907fb01.tar.gz
Fixes tests, use correct config file name
Diffstat (limited to 'internal')
-rw-r--r--internal/admin/model.go13
-rw-r--r--internal/admin/model_test.go4
-rw-r--r--internal/admin/service.go2
3 files changed, 13 insertions, 6 deletions
diff --git a/internal/admin/model.go b/internal/admin/model.go
index 1b3da00..d9eea03 100644
--- a/internal/admin/model.go
+++ b/internal/admin/model.go
@@ -10,9 +10,13 @@ import (
"os"
"path/filepath"
- "gopkg.in/yaml.v2"
+ "github.com/go-git/go-billy/v5/osfs"
+ "github.com/go-git/go-git/v5"
+ "github.com/go-git/go-git/v5/storage/filesystem"
"gopkg.in/ini.v1"
+
+ "sigs.k8s.io/yaml"
)
const (
@@ -137,6 +141,9 @@ func (r *GitRepo) ReconcileRepo(basePath string) {
_, err := os.Stat(repoBase)
if errors.Is(err, fs.ErrNotExist) {
// if no exist -> init bare
+ fs := osfs.New(repoBase)
+ strg := filesystem.NewStorage(fs, nil)
+ _, _ = git.Init(strg, nil)
}
r.ConfigureExport(repoBase)
@@ -171,10 +178,10 @@ func (r *GitRepo) ConfigureExport(repoBase string) {
// ReconcileGitConf reconcile gitweb configuration section of gitconfig
func (r *GitWeb) ReconcileGitConf(repoBase string) {
- confPath := filepath.Join(repoBase, "conf")
+ confPath := filepath.Join(repoBase, "config")
cfg, err := ini.Load(confPath)
if err != nil {
- log.Fatal("Coudln't read gitconfig")
+ log.Fatalf("Coudln't read gitconfig %s", err)
}
// check if empty, delete
if (GitWeb{} == *r) {
diff --git a/internal/admin/model_test.go b/internal/admin/model_test.go
index e8f6e33..85ca8f4 100644
--- a/internal/admin/model_test.go
+++ b/internal/admin/model_test.go
@@ -78,9 +78,9 @@ func TestConfigReconcile(t *testing.T) {
tempDir := t.TempDir()
// make "fake" repo
testRepo := filepath.Join(tempDir, "testrepo.git")
- testConf := filepath.Join(testRepo, "conf")
+ testConf := filepath.Join(testRepo, "config")
os.Mkdir(testRepo, 0750)
- f, err := os.Create(filepath.Join(testRepo, "conf"))
+ f, err := os.Create(filepath.Join(testRepo, "config"))
if err != nil {
t.Fatalf("couldn't create testdir, %s", err)
}
diff --git a/internal/admin/service.go b/internal/admin/service.go
index c09ad66..80056b7 100644
--- a/internal/admin/service.go
+++ b/internal/admin/service.go
@@ -18,7 +18,7 @@ func (s *Servicer) InitServer() {
s.AddPolicies(policies)
s.SavePolicy()
s.LoadPolicy()
- s.Conf.ServerPolicies()
+ s.Conf.ConfigureRepos()
}
// NewService create a new admin service, load config, and generate policies