Git Repository
1
package main
2
3
import (
4
    "os/exec"
5
    "fmt"
6
)
7
8
type GitRepository struct {
9
    RepositoryInfo
10
}
11
12
func (repo *GitRepository) GetName() string {
13
    return repo.Name
14
}
15
16
func (repo *GitRepository) GetPath() string {
17
    return repo.Path
18
}
19
20
// GetFile implementation - returns the file bytes
21
// after executing cd /path/to/repo ; git show sha
22
// This cmd is returning an empty byte[] for me atm, need to investigate later
23
func (repo *GitRepository) GetFile(id string) []byte {
24
    out, _ := exec.Command("cd", repo.Path, ";", "git", "show", id).Output()
25
    fmt.Println(out)
26
    return out
27
}
28
29
// GetFileExists implementation - returns true if the file exists
30
// after executing cd /path/to/repo ; git show sha
31
func (repo *GitRepository) GetFileExists(id string) bool {
32
    cmd := exec.Command("cd", repo.Path, ";", "git", "show", id)
33
    return cmd.Run() == nil
34
}
Loading...