diff options
author | Michael Muré <batolettre@gmail.com> | 2018-07-12 15:14:37 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-07-12 21:32:09 +0200 |
commit | cda8114fda8d349bbaeefb42cc33ba715d41cf08 (patch) | |
tree | 45c96a8d07db89ff66519ae1e29b44648c1b5e37 /repository | |
parent | df67212fee5ae5381b13b2c7d6ce92e1bdb66e0f (diff) | |
download | git-bug-cda8114fda8d349bbaeefb42cc33ba715d41cf08.tar.gz |
store user info in the datastore
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) } |