aboutsummaryrefslogtreecommitdiffstats
path: root/bug
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-12 12:44:46 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-12 12:44:46 +0200
commitc498674718608a1171a4fcef6f26184df7d5fa7b (patch)
tree9cc53ea07b61d52b12cd5fa3367b25d04bebc150 /bug
parentd0443659123f912e9385e27efebe4b7da65aa2f6 (diff)
downloadgit-bug-c498674718608a1171a4fcef6f26184df7d5fa7b.tar.gz
add the new bug command with a very primitive bug datastructure
Diffstat (limited to 'bug')
-rw-r--r--bug/bug.go6
-rw-r--r--bug/comment.go6
-rw-r--r--bug/person.go31
3 files changed, 43 insertions, 0 deletions
diff --git a/bug/bug.go b/bug/bug.go
new file mode 100644
index 00000000..08743e85
--- /dev/null
+++ b/bug/bug.go
@@ -0,0 +1,6 @@
+package bug
+
+type Bug struct {
+ Title string
+ Comments []Comment
+}
diff --git a/bug/comment.go b/bug/comment.go
new file mode 100644
index 00000000..f7727709
--- /dev/null
+++ b/bug/comment.go
@@ -0,0 +1,6 @@
+package bug
+
+type Comment struct {
+ Author Person
+ Message string
+}
diff --git a/bug/person.go b/bug/person.go
new file mode 100644
index 00000000..41f37ef4
--- /dev/null
+++ b/bug/person.go
@@ -0,0 +1,31 @@
+package bug
+
+import (
+ "github.com/MichaelMure/git-bug/repository"
+ "github.com/pkg/errors"
+)
+
+type Person struct {
+ Name string
+ Email string
+}
+
+func GetUser(repo repository.Repo) (Person, error) {
+ name, err := repo.GetUserName()
+ if err != nil {
+ return Person{}, err
+ }
+ if name == "" {
+ return Person{}, errors.New("User name is not configured in git yet. Please use `git config --global user.name \"John Doe\"`")
+ }
+
+ email, err := repo.GetUserEmail()
+ if err != nil {
+ return Person{}, err
+ }
+ if email == "" {
+ return Person{}, errors.New("User name is not configured in git yet. Please use `git config --global user.email johndoe@example.com`")
+ }
+
+ return Person{Name: name, Email: email}, nil
+}