ece7523ade23d86d6ec4a7d71fc13dae739547ff

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix: set allow keyless when no public keys provided

Diff

 1diff --git a/internal/config/config.go b/internal/config/config.go
 2index bfacc99ed021e974f160feaae4008cd93b6b1f76..f1c1ca31f0de50a71a737cf98d33dbf2127f89aa 100644
 3--- a/internal/config/config.go
 4+++ b/internal/config/config.go
 5@@ -97,7 +97,12 @@ func NewConfig(cfg *config.Config) (*Config, error) {
 6 	} else {
 7 		displayHost = host
 8 	}
 9-	yamlConfig := fmt.Sprintf(defaultConfig, displayHost, port, anonAccess)
10+	yamlConfig := fmt.Sprintf(defaultConfig,
11+		displayHost,
12+		port,
13+		anonAccess,
14+		len(pks) == 0,
15+	)
16 	if len(pks) == 0 {
17 		yamlUsers = defaultUserConfig
18 	} else {
19@@ -186,6 +191,7 @@ func (cfg *Config) createDefaultConfigRepo(yaml string) error {
20 	rs := cfg.Source
21 	err := rs.LoadRepo(cn)
22 	if os.IsNotExist(err) {
23+		log.Printf("creating default config repo %s", cn)
24 		repo, err := ggit.PlainInit(rp, true)
25 		if err != nil {
26 			return err
27diff --git a/internal/config/defaults.go b/internal/config/defaults.go
28index 052e6a1f6418585666b58f25a565b21d974da322..295c93487e11fc8cd243ad06f2bb98f6c0f29809 100644
29--- a/internal/config/defaults.go
30+++ b/internal/config/defaults.go
31@@ -17,7 +17,7 @@ anon-access: %s
32 
33 # You can grant read-only access to users without private keys. Any password
34 # will be accepted.
35-allow-keyless: false
36+allow-keyless: %t
37 
38 # Customize repo display in the menu.
39 repos:
40diff --git a/internal/git/git.go b/internal/git/git.go
41index f755465c30f9c43072a263385756a23a6569d487..89762d524c558aecdf42552c0e75fb20a0abb7a7 100644
42--- a/internal/git/git.go
43+++ b/internal/git/git.go
44@@ -201,7 +201,6 @@ func (rs *RepoSource) LoadRepo(name string) error {
45 	rp := filepath.Join(rs.Path, name)
46 	r, err := rs.open(rp)
47 	if err != nil {
48-		log.Printf("error opening repository %s: %s", name, err)
49 		return err
50 	}
51 	rs.repos[name] = r