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 later
func (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 sha
func (repo *GitRepository) GetFileExists(id string) bool {
cmd := exec.Command("cd", repo.Path, ";", "git", "show", id)
return cmd.Run() == nil
}