fix(config): use repo path in logs

Ayman Bagabas created

Change summary

config/auth.go | 42 ++++++++++++++++++++++--------------------
config/git.go  |  4 ++--
2 files changed, 24 insertions(+), 22 deletions(-)

Detailed changes

config/auth.go 🔗

@@ -86,29 +86,31 @@ func (cfg *Config) accessForKey(repo string, pk ssh.PublicKey) gm.AccessLevel {
 	anon := cfg.anonAccessLevel()
 	private := cfg.isPrivate(repo)
 	// Find user
-	for _, user := range cfg.Users {
-		for _, k := range user.PublicKeys {
-			apk, _, _, _, err := ssh.ParseAuthorizedKey([]byte(strings.TrimSpace(k)))
-			if err != nil {
-				log.Printf("error: malformed authorized key: '%s'", k)
-				return gm.NoAccess
-			}
-			if ssh.KeysEqual(pk, apk) {
-				if user.Admin {
-					return gm.AdminAccess
+	if pk != nil {
+		for _, user := range cfg.Users {
+			for _, k := range user.PublicKeys {
+				apk, _, _, _, err := ssh.ParseAuthorizedKey([]byte(strings.TrimSpace(k)))
+				if err != nil {
+					log.Printf("error: malformed authorized key: '%s'", k)
+					return gm.NoAccess
 				}
-				u := user
-				if cfg.isCollab(repo, &u) {
-					if anon > gm.ReadWriteAccess {
-						return anon
+				if ssh.KeysEqual(pk, apk) {
+					if user.Admin {
+						return gm.AdminAccess
 					}
-					return gm.ReadWriteAccess
-				}
-				if !private {
-					if anon > gm.ReadOnlyAccess {
-						return anon
+					u := user
+					if cfg.isCollab(repo, &u) {
+						if anon > gm.ReadWriteAccess {
+							return anon
+						}
+						return gm.ReadWriteAccess
+					}
+					if !private {
+						if anon > gm.ReadOnlyAccess {
+							return anon
+						}
+						return gm.ReadOnlyAccess
 					}
-					return gm.ReadOnlyAccess
 				}
 			}
 		}

config/git.go 🔗

@@ -237,9 +237,9 @@ func (rs *RepoSource) LoadRepo(name string) error {
 		return err
 	}
 	if !r.IsBare() {
-		log.Printf("warning: %q is not a bare repository", rp)
+		log.Printf("warning: %q is not a bare repository", r.Path())
 	} else if r.IsBare() && !strings.HasSuffix(rp, ".git") {
-		log.Printf("warning: %q should be renamed to %q", rp, rp+".git")
+		log.Printf("warning: %q should be renamed to %q", r.Path(), r.Path()+".git")
 	}
 	rs.repos[name] = r
 	return nil