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