diff options
| author | 2026-03-29 13:31:16 +0000 | |
|---|---|---|
| committer | 2026-03-29 13:31:16 +0000 | |
| commit | ad880cd26c9a6e4739d9ced8c5a076bccaceb999 (patch) | |
| tree | f18d44acd1c2a414396c1d40c87af84cb815c65f /cmd/show-object/run.go | |
| parent | cmd/receivepack9418: Remove the silly runMain thingy (diff) | |
| signature | No signature | |
cmd/show-object: Split files
Diffstat (limited to 'cmd/show-object/run.go')
| -rw-r--r-- | cmd/show-object/run.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/cmd/show-object/run.go b/cmd/show-object/run.go new file mode 100644 index 00000000..f1a6fc6d --- /dev/null +++ b/cmd/show-object/run.go @@ -0,0 +1,45 @@ +package main + +import ( + "fmt" + "os" + + "codeberg.org/lindenii/furgit/repository" +) + +func run(repoPath, name *string) error { + root, err := os.OpenRoot(*repoPath) + if err != nil { + return fmt.Errorf("open repo root: %w", err) + } + + defer func() { _ = root.Close() }() + + repo, err := repository.Open(root) + if err != nil { + return fmt.Errorf("open repository: %w", err) + } + + id, err := resolveInput(repo, *name) + if err != nil { + _ = repo.Close() + + return fmt.Errorf("resolve %q: %w", *name, err) + } + + s, err := repo.Fetcher().ExactObject(id) + if err != nil { + _ = repo.Close() + + return fmt.Errorf("read object %s: %w", id, err) + } + + printStored(s) + + err = repo.Close() + if err != nil { + return fmt.Errorf("close repository: %w", err) + } + + return nil +} |
