feat: detect private repos

Ayman Bagabas created

Change summary

config/config.go | 8 +++++---
config/git.go    | 6 ++++++
2 files changed, 11 insertions(+), 3 deletions(-)

Detailed changes

config/config.go 🔗

@@ -154,6 +154,7 @@ func (cfg *Config) Reload() error {
 				rp = rr.Readme
 				r.name = rr.Name
 				r.description = rr.Note
+				r.private = rr.Private
 				break
 			}
 		}
@@ -232,14 +233,15 @@ func (cfg *Config) createDefaultConfigRepo(yaml string) error {
 		if err != nil {
 			return err
 		}
-		author := &object.Signature{
+		author := object.Signature{
 			Name:  "Soft Serve Server",
 			Email: "vt100@charm.sh",
 			When:  time.Now(),
 		}
 		_, err = wt.Commit("Default init", &ggit.CommitOptions{
-			All:    true,
-			Author: author,
+			All:       true,
+			Author:    &author,
+			Committer: &author,
 		})
 		if err != nil {
 			return err

config/git.go 🔗

@@ -26,6 +26,7 @@ type Repo struct {
 	head        *git.Reference
 	refs        []*git.Reference
 	patchCache  *lru.Cache
+	private     bool
 }
 
 // open opens a Git repository.
@@ -50,6 +51,11 @@ func (rs *RepoSource) open(path string) (*Repo, error) {
 	return r, nil
 }
 
+// IsPrivate returns true if the repository is private.
+func (r *Repo) IsPrivate() bool {
+	return r.private
+}
+
 // Path returns the path to the repository.
 func (r *Repo) Path() string {
 	return r.path