File tree Expand file tree Collapse file tree 4 files changed +15
-6
lines changed
Expand file tree Collapse file tree 4 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ import (
2020 "github.com/spf13/cobra"
2121)
2222
23- var version = "1.2.3 "
23+ var version = "1.2.4 "
2424
2525var rootCmd = & cobra.Command {
2626 Use : "git-profile" ,
Original file line number Diff line number Diff line change @@ -49,12 +49,12 @@ func runUnset(cmd *cobra.Command, _ []string) {
4949
5050 err := internal .UnsetUserName (global )
5151 if err != nil {
52- fmt .Println ( err )
52+ fmt .Printf ( "error: %v \n " , err )
5353 }
5454
5555 err = internal .UnsetUserEmail (global )
5656 if err != nil {
57- fmt .Println ( err )
57+ fmt .Printf ( "error: %v \n \n " , err )
5858 }
5959}
6060
Original file line number Diff line number Diff line change @@ -4,8 +4,17 @@ import "fmt"
44
55type NotSetError struct {
66 ConfigName string
7+ Global bool
78}
89
910func (e * NotSetError ) Error () string {
10- return fmt .Sprintf ("no local %s set" , e .ConfigName )
11+ var configType string
12+
13+ if e .Global {
14+ configType = "global"
15+ } else {
16+ configType = "local"
17+ }
18+
19+ return fmt .Sprintf ("no %s %s set" , configType , e .ConfigName )
1120}
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ func GetGlobalUserName() (string, error) {
195195
196196 ok := errors .As (err , & exitError )
197197 if ok && exitError .ExitCode () == 1 && err .Error () == "exit status 1" {
198- return "" , & custom_errors.NotSetError {ConfigName : "global username" }
198+ return "" , & custom_errors.NotSetError {ConfigName : "username" , Global : true }
199199 } else {
200200 return "" , err
201201 }
@@ -215,7 +215,7 @@ func GetGlobalUserEmail() (string, error) {
215215
216216 ok := errors .As (err , & exitError )
217217 if ok && exitError .ExitCode () == 1 && err .Error () == "exit status 1" {
218- return "" , & custom_errors.NotSetError {ConfigName : "global email" }
218+ return "" , & custom_errors.NotSetError {ConfigName : "email" , Global : true }
219219 } else {
220220 return "" , err
221221 }
You can’t perform that action at this time.
0 commit comments