aboutsummaryrefslogtreecommitdiff
path: root/pkg/service/git.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/service/git.go')
-rw-r--r--pkg/service/git.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/service/git.go b/pkg/service/git.go
index 6bb6e9e..cbee90a 100644
--- a/pkg/service/git.go
+++ b/pkg/service/git.go
@@ -1,7 +1,9 @@
package service
import (
+ "compress/gzip"
"errors"
+ "io"
"log/slog"
"git.gabrielgio.me/cerrado/pkg/config"
@@ -92,6 +94,29 @@ func (g *GitService) ListCommits(name, ref string, count int) ([]*object.Commit,
return repo.Commits(count)
}
+func (g *GitService) WriteTarGZip(w io.Writer, name, ref string, filename string) error {
+ r := g.configRepo.GetByName(name)
+ if r == nil {
+ return RepositoryNotFoundErr
+ }
+
+ repo, err := git.OpenRepository(r.Path)
+ if err != nil {
+ return err
+ }
+
+ err = repo.SetRef(ref)
+ if err != nil {
+ return err
+ }
+
+ gw := gzip.NewWriter(w)
+ defer gw.Close()
+
+ return repo.WriteTar(gw, filename)
+
+}
+
func (g *GitService) GetTree(name, ref, path string) (*object.Tree, error) {
r := g.configRepo.GetByName(name)
if r == nil {