diff options
Diffstat (limited to 'repository')
-rw-r--r-- | repository/git.go | 11 | ||||
-rw-r--r-- | repository/repo.go | 5 |
2 files changed, 16 insertions, 0 deletions
diff --git a/repository/git.go b/repository/git.go index 309641f6..679d24fc 100644 --- a/repository/git.go +++ b/repository/git.go @@ -114,6 +114,17 @@ func (repo *GitRepo) PushRefs(remote string, refPattern string) error { return nil } +// StoreData will store arbitrary data and return the corresponding hash +func (repo *GitRepo) StoreData(data []byte) (Hash, error) { + var stdin = bytes.NewReader(data) + var stdout bytes.Buffer + var stderr bytes.Buffer + + err := repo.runGitCommandWithIO(stdin, &stdout, &stderr, "hash-object", "--stdin", "-w") + + return Hash(stdout.String()), err +} + /* // //// GetSubmitStrategy returns the way in which a review is submitted diff --git a/repository/repo.go b/repository/repo.go index 11bb132e..ef7215ee 100644 --- a/repository/repo.go +++ b/repository/repo.go @@ -1,6 +1,8 @@ // Package repository contains helper methods for working with a Git repo. package repository +type Hash string + // Repo represents a source code repository. type Repo interface { // GetPath returns the path to the repo. @@ -20,4 +22,7 @@ type Repo interface { // PushRefs push git refs to a remote PushRefs(remote string, refPattern string) error + + // StoreData will store arbitrary data and return the corresponding hash + StoreData([]byte) (Hash, error) } |