1// Package repo runs git against bare repositories.
2package repo
3
4import (
5 "os/exec"
6 "strings"
7)
8
9// Git runs git against the repository at dir and returns its trimmed output.
10func Git(dir string, args ...string) (string, error) {
11 out, err := exec.Command("git", append([]string{"--git-dir", dir}, args...)...).Output()
12 return strings.TrimSpace(string(out)), err
13}
14
15// Blob is the exact bytes of a file at a revision, as "HEAD:path".
16func Blob(dir, rev string) ([]byte, error) {
17 return exec.Command("git", "--git-dir", dir, "cat-file", "blob", rev).Output()
18}