Make reclone output more detailed (#457)

This commit is contained in:
gabrie30
2024-09-20 19:52:06 -07:00
committed by GitHub
parent 9e64a97d63
commit ca104ddd8b
2 changed files with 14 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
## [1.10.1] - unreleased
### Added
- Reclone name and description to reclone output
### Changed
### Deprecated
### Removed

View File

@@ -73,15 +73,16 @@ func reCloneFunc(cmd *cobra.Command, argz []string) {
}
if len(argz) == 0 {
for _, key := range mapOfReClones {
runReClone(key)
for rcIdentifier, reclone := range mapOfReClones {
runReClone(reclone, rcIdentifier)
}
} else {
for _, arg := range argz {
if _, ok := mapOfReClones[arg]; !ok {
colorlog.PrintErrorAndExit(fmt.Sprintf("ERROR: The key %v was not found in reclone.yaml", arg))
for _, rcIdentifier := range argz {
if _, ok := mapOfReClones[rcIdentifier]; !ok {
colorlog.PrintErrorAndExit(fmt.Sprintf("ERROR: The key %v was not found in reclone.yaml", rcIdentifier))
} else {
runReClone(mapOfReClones[rcIdentifier], rcIdentifier)
}
runReClone(mapOfReClones[arg])
}
}
@@ -130,7 +131,7 @@ func sanitizeCmd(cmd string) string {
return cmd
}
func runReClone(rc ReClone) {
func runReClone(rc ReClone, rcIdentifier string) {
// make sure command starts with ghorg clone
splitCommand := strings.Split(rc.Cmd, " ")
ghorg, clone, remainingCommand := splitCommand[0], splitCommand[1], splitCommand[1:]
@@ -143,6 +144,11 @@ func runReClone(rc ReClone) {
if !isQuietReClone() {
fmt.Println("")
colorlog.PrintInfo(fmt.Sprintf("Running reclone: %v", rcIdentifier))
if rc.Description != "" {
colorlog.PrintInfo(fmt.Sprintf("Description: %v", rc.Description))
fmt.Println("")
}
colorlog.PrintInfo(fmt.Sprintf("> %v", safeToLogCmd))
}