1package bug
2
3import (
4 "errors"
5 "github.com/MichaelMure/git-bug/repository"
6)
7
8type Person struct {
9 Name string
10 Email string
11}
12
13// GetUser will query the repository for user detail and build the corresponding Person
14func GetUser(repo repository.Repo) (Person, error) {
15 name, err := repo.GetUserName()
16 if err != nil {
17 return Person{}, err
18 }
19 if name == "" {
20 return Person{}, errors.New("User name is not configured in git yet. Please use `git config --global user.name \"John Doe\"`")
21 }
22
23 email, err := repo.GetUserEmail()
24 if err != nil {
25 return Person{}, err
26 }
27 if email == "" {
28 return Person{}, errors.New("User name is not configured in git yet. Please use `git config --global user.email johndoe@example.com`")
29 }
30
31 return Person{Name: name, Email: email}, nil
32}