aboutsummaryrefslogtreecommitdiffstats
path: root/bug
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-12 15:14:37 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-12 21:32:09 +0200
commitcda8114fda8d349bbaeefb42cc33ba715d41cf08 (patch)
tree45c96a8d07db89ff66519ae1e29b44648c1b5e37 /bug
parentdf67212fee5ae5381b13b2c7d6ce92e1bdb66e0f (diff)
downloadgit-bug-cda8114fda8d349bbaeefb42cc33ba715d41cf08.tar.gz
store user info in the datastore
Diffstat (limited to 'bug')
-rw-r--r--bug/bug.go1
-rw-r--r--bug/person.go19
2 files changed, 18 insertions, 2 deletions
diff --git a/bug/bug.go b/bug/bug.go
index 08743e85..33da1326 100644
--- a/bug/bug.go
+++ b/bug/bug.go
@@ -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)
+}