git-bug/bug/person.go

33 lines
784 B
Go
Raw Normal View History

package bug
import (
2018-07-13 17:13:40 +03:00
"errors"
"github.com/MichaelMure/git-bug/repository"
)
type Person struct {
2018-08-01 03:15:40 +03:00
Name string
Email string
}
2018-07-12 16:14:37 +03:00
// 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 {
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
}