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 /bug | |
parent | df67212fee5ae5381b13b2c7d6ce92e1bdb66e0f (diff) | |
download | git-bug-cda8114fda8d349bbaeefb42cc33ba715d41cf08.tar.gz |
store user info in the datastore
Diffstat (limited to 'bug')
-rw-r--r-- | bug/bug.go | 1 | ||||
-rw-r--r-- | bug/person.go | 19 |
2 files changed, 18 insertions, 2 deletions
@@ -4,3 +4,4 @@ type Bug struct { Title string Comments []Comment } + diff --git a/bug/person.go b/bug/person.go index 41f37ef4..05cc43fa 100644 --- a/bug/person.go +++ b/bug/person.go @@ -1,15 +1,17 @@ package bug import ( + "encoding/json" "github.com/MichaelMure/git-bug/repository" "github.com/pkg/errors" ) type Person struct { - Name string - Email string + Name string `json:"name"` + Email string `json:"email"` } +// GetUser will query the repository for user detail and build the corresponding Person func GetUser(repo repository.Repo) (Person, error) { name, err := repo.GetUserName() if err != nil { @@ -29,3 +31,16 @@ func GetUser(repo repository.Repo) (Person, error) { return Person{Name: name, Email: email}, nil } + +// 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) { + + data, err := json.Marshal(person) + + if err != nil { + return "", err + } + + return repo.StoreData(data) +} |