diff --git a/bug/comment.go b/bug/comment.go index f7727709f49a5f2b46a154fd8552b8b126772c4c..edd5666c5ba8e72b96385c6e654c499ca88bc4f5 100644 --- a/bug/comment.go +++ b/bug/comment.go @@ -1,6 +1,9 @@ package bug +import "github.com/MichaelMure/git-bug/util" + type Comment struct { Author Person Message string + Media []util.Hash } diff --git a/bug/person.go b/bug/person.go index 05cc43fa6d8372436365a3b2369f1d0f202b97b9..d47bc150f36726bf3c7c72e715ecccadee3c3a3d 100644 --- a/bug/person.go +++ b/bug/person.go @@ -3,6 +3,7 @@ package bug import ( "encoding/json" "github.com/MichaelMure/git-bug/repository" + "github.com/MichaelMure/git-bug/util" "github.com/pkg/errors" ) @@ -34,7 +35,7 @@ func GetUser(repo repository.Repo) (Person, error) { // Store will convert the Person to JSON and store it in the internal git datastore // Return the git hash handle of the data -func (person *Person) Store(repo repository.Repo) (repository.Hash, error) { +func (person *Person) Store(repo repository.Repo) (util.Hash, error) { data, err := json.Marshal(person) diff --git a/repository/git.go b/repository/git.go index 679d24fce21c81a4946447e9c74bbfb101eb5485..b41bc95ce072231f0d3a60d4908298d4ddfbcd34 100644 --- a/repository/git.go +++ b/repository/git.go @@ -5,6 +5,7 @@ import ( "bytes" "crypto/sha1" "fmt" + "github.com/MichaelMure/git-bug/util" "io" "os" "os/exec" @@ -115,14 +116,14 @@ func (repo *GitRepo) PushRefs(remote string, refPattern string) error { } // StoreData will store arbitrary data and return the corresponding hash -func (repo *GitRepo) StoreData(data []byte) (Hash, error) { +func (repo *GitRepo) StoreData(data []byte) (util.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 + return util.Hash(stdout.String()), err } /* diff --git a/repository/repo.go b/repository/repo.go index ef7215ee81b3897867eabda66cce2ab6ff7d8827..2611324f0283c4b994daf7f1547de5db6cd0c6f2 100644 --- a/repository/repo.go +++ b/repository/repo.go @@ -1,7 +1,7 @@ // Package repository contains helper methods for working with a Git repo. package repository -type Hash string +import "github.com/MichaelMure/git-bug/util" // Repo represents a source code repository. type Repo interface { @@ -24,5 +24,5 @@ type Repo interface { PushRefs(remote string, refPattern string) error // StoreData will store arbitrary data and return the corresponding hash - StoreData([]byte) (Hash, error) + StoreData([]byte) (util.Hash, error) } diff --git a/util/hash.go b/util/hash.go new file mode 100644 index 0000000000000000000000000000000000000000..088fd70e61f1ac608757e50a1b320b39c5a7097a --- /dev/null +++ b/util/hash.go @@ -0,0 +1,3 @@ +package util + +type Hash string