aboutsummaryrefslogtreecommitdiff
path: root/repository/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'repository/config.go')
-rw-r--r--repository/config.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/repository/config.go b/repository/config.go
new file mode 100644
index 00000000..de33e2c3
--- /dev/null
+++ b/repository/config.go
@@ -0,0 +1,32 @@
+package repository
+
+import (
+ "fmt"
+ "os"
+
+ "codeberg.org/lindenii/furgit/config"
+)
+
+func parseRepositoryConfig(root *os.Root) (*config.Config, error) {
+ configFile, err := root.Open("config")
+ if err != nil {
+ return nil, fmt.Errorf("repository: open config: %w", err)
+ }
+
+ defer func() { _ = configFile.Close() }()
+
+ cfg, err := config.ParseConfig(configFile)
+ if err != nil {
+ return nil, fmt.Errorf("repository: parse config: %w", err)
+ }
+
+ return cfg, nil
+}
+
+// Config returns the parsed repository configuration snapshot.
+//
+// The returned pointer is owned by Repository. Callers should treat it as
+// read-only.
+func (repo *Repository) Config() *config.Config {
+ return repo.config
+}