package main
import (
"os/exec"
"fmt"
)type GitRepository struct {
RepositoryInfo
}func (repo *GitRepository) GetName() string {
return repo.Name
}func (repo *GitRepository) GetPath() string {
return repo.Path
}// GetFile implementation - returns the file bytes// after executing cd /path/to/repo ; git show sha// This cmd is returning an empty byte[] for me atm, need to investigate laterfunc (repo *GitRepository) GetFile(id string) []byte {
out, _ := exec.Command("cd", repo.Path, ";", "git", "show", id).Output()
fmt.Println(out)
return out
}// GetFileExists implementation - returns true if the file exists// after executing cd /path/to/repo ; git show shafunc (repo *GitRepository) GetFileExists(id string) bool {
cmd := exec.Command("cd", repo.Path, ";", "git", "show", id)
return cmd.Run() == nil
}Git Repository
| config.json | |
|---|---|
| 1 | { |
| 2 | "repositories":[ |
| 3 | {"name":"testrepo", "path":"/home/j/src/git-sandbox", "scm":"git"} |
| 4 | ] |
| 5 | } |