diff --git a/cmd/gogitlabber/git.go b/cmd/gogitlabber/git.go index f050c1d..e9cb50a 100644 --- a/cmd/gogitlabber/git.go +++ b/cmd/gogitlabber/git.go @@ -149,8 +149,12 @@ func pullRepository(repoName string, repoDestination string) { switch { case strings.Contains(string(pullOutput), "You have unstaged changes"): - pullErrorMsg = append(pullErrorMsg, repoDestination) - logger.Print("Found unstaged changes for repository: "+repoName+" at "+repoDestination, nil) + pullErrorMsgUnstaged = append(pullErrorMsgUnstaged, repoDestination) + logger.Print("Found unstaged changes in repository: "+repoName+" at "+repoDestination, nil) + + case strings.Contains(string(pullOutput), "Your index contains uncommitted changes"): + pullErrorMsgUncommitted = append(pullErrorMsgUncommitted, repoDestination) + logger.Print("Found uncommitted changes in repository: "+repoName+" at "+repoDestination, nil) default: logger.Print("ERROR: pulling "+repoName, nil) diff --git a/cmd/gogitlabber/main.go b/cmd/gogitlabber/main.go index 5d43689..b9df47c 100644 --- a/cmd/gogitlabber/main.go +++ b/cmd/gogitlabber/main.go @@ -22,7 +22,8 @@ var gitBackend string var clonedCount int var errorCount int var pulledCount int -var pullErrorMsg []string +var pullErrorMsgUnstaged []string +var pullErrorMsgUncommitted []string // repository data type Repository struct { @@ -76,5 +77,6 @@ func main() { // manage found repositories checkoutRepositories(repositories, concurrency) printSummary() - printPullError(pullErrorMsg) + printPullErrorUnstaged(pullErrorMsgUnstaged) + printPullErrorUncommitted(pullErrorMsgUncommitted) } diff --git a/cmd/gogitlabber/output.go b/cmd/gogitlabber/output.go index 6f7953e..156b3d8 100644 --- a/cmd/gogitlabber/output.go +++ b/cmd/gogitlabber/output.go @@ -49,10 +49,18 @@ func printSummary() { ) } -func printPullError(pullErrorMsg []string) { - if len(pullErrorMsg) > 0 { - for _, repo := range pullErrorMsg { +func printPullErrorUnstaged(pullErrorMsgUnstaged []string) { + if len(pullErrorMsgUnstaged) > 0 { + for _, repo := range pullErrorMsgUnstaged { fmt.Printf("❕%s has unstaged changes.\n", repo) } } } + +func printPullErrorUncommitted(pullErrorMsgUncommitted []string) { + if len(pullErrorMsgUncommitted) > 0 { + for _, repo := range pullErrorMsgUncommitted { + fmt.Printf("❕%s has uncommitted changes.\n", repo) + } + } +}