Skip to content

Commit 7838aa7

Browse files
committed
Merge branch 'master' of https://github.com/gabrie30/ghorg
2 parents 35dda34 + 7222d63 commit 7838aa7

File tree

5 files changed

+18
-40
lines changed

5 files changed

+18
-40
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55

6-
## [1.9.14] - unreleased
6+
## [1.10.00] - unreleased
77
### Added
88
- GHORG_NO_DIR_SIZE flag to turn off directory size output which is now enabled by default
99
- GHORG_STATS_ENABLED flag to track clone data over time, set to false by default
@@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
1212
### Changed
1313
### Deprecated
1414
### Removed
15+
- GHORG_RECLONE_VERBOSE flag
1516
### Fixed
1617
### Security
1718
- Bump code.gitea.io/sdk/gitea from 0.18.0 to 0.19.0 (#441)
@@ -287,7 +288,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
287288
### Security
288289
## [1.8.2] - 7/6/22
289290
### Added
290-
- GHORG_RECLONE_VERBOSE flag
291291
- GHORG_RECLONE_QUIET flag
292292
### Changed
293293
- reclone logging format

cmd/reclone.go

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cmd
22

33
import (
4-
"bufio"
54
"fmt"
65
"os"
76
"os/exec"
@@ -25,10 +24,6 @@ type ReClone struct {
2524
Description string `yaml:"description"`
2625
}
2726

28-
func isVerboseReClone() bool {
29-
return os.Getenv("GHORG_RECLONE_VERBOSE") == "true"
30-
}
31-
3227
func isQuietReClone() bool {
3328
return os.Getenv("GHORG_RECLONE_QUIET") == "true"
3429
}
@@ -40,10 +35,6 @@ func reCloneFunc(cmd *cobra.Command, argz []string) {
4035
os.Setenv("GHORG_RECLONE_PATH", path)
4136
}
4237

43-
if cmd.Flags().Changed("verbose") {
44-
os.Setenv("GHORG_RECLONE_VERBOSE", "true")
45-
}
46-
4738
if cmd.Flags().Changed("quiet") {
4839
os.Setenv("GHORG_RECLONE_QUIET", "true")
4940
}
@@ -81,10 +72,6 @@ func reCloneFunc(cmd *cobra.Command, argz []string) {
8172
os.Exit(0)
8273
}
8374

84-
if !isVerboseReClone() && !isQuietReClone() {
85-
asciiTime()
86-
}
87-
8875
if len(argz) == 0 {
8976
for _, key := range mapOfReClones {
9077
runReClone(key)
@@ -155,7 +142,8 @@ func runReClone(rc ReClone) {
155142
safeToLogCmd := sanitizeCmd(strings.Clone(rc.Cmd))
156143

157144
if !isQuietReClone() {
158-
colorlog.PrintInfo(fmt.Sprintf("$ %v", safeToLogCmd))
145+
fmt.Println("")
146+
colorlog.PrintInfo(fmt.Sprintf("> %v", safeToLogCmd))
159147
}
160148

161149
ghorgClone := exec.Command("ghorg", remainingCommand...)
@@ -175,7 +163,7 @@ func runReClone(rc ReClone) {
175163
ghorgEnv := strings.HasPrefix(env, "GHORG_")
176164

177165
// skip global flags and reclone flags which are set in the conf.yaml
178-
if env == "GHORG_COLOR" || env == "GHORG_CONFIG" || env == "GHORG_RECLONE_VERBOSE" || env == "GHORG_RECLONE_QUIET" || env == "GHORG_RECLONE_PATH" || env == "GHORG_RECLONE_RUNNING" {
166+
if env == "GHORG_COLOR" || env == "GHORG_CONFIG" || env == "GHORG_RECLONE_QUIET" || env == "GHORG_RECLONE_PATH" || env == "GHORG_RECLONE_RUNNING" {
179167
continue
180168
}
181169
if ghorgEnv {
@@ -184,27 +172,26 @@ func runReClone(rc ReClone) {
184172
}
185173
}
186174

187-
stdout, err := ghorgClone.StdoutPipe()
188-
if err != nil {
189-
colorlog.PrintErrorAndExit(fmt.Sprintf("ERROR: Problem with piping to stdout, err: %v", err))
175+
// Connect ghorgClone's stdout and stderr to the current process's stdout and stderr
176+
if !isQuietReClone() {
177+
ghorgClone.Stdout = os.Stdout
178+
ghorgClone.Stderr = os.Stderr
179+
} else {
180+
spinningSpinner.Start()
181+
defer spinningSpinner.Stop()
182+
ghorgClone.Stdout = nil
183+
ghorgClone.Stderr = nil
190184
}
191185

192-
err = ghorgClone.Start()
193-
186+
err := ghorgClone.Start()
194187
if err != nil {
188+
spinningSpinner.Stop()
195189
colorlog.PrintErrorAndExit(fmt.Sprintf("ERROR: Starting ghorg clone cmd: %v, err: %v", safeToLogCmd, err))
196190
}
197191

198-
if isVerboseReClone() && !isQuietReClone() {
199-
scanner := bufio.NewScanner(stdout)
200-
for scanner.Scan() {
201-
m := scanner.Text()
202-
fmt.Println(m)
203-
}
204-
}
205-
206192
err = ghorgClone.Wait()
207193
if err != nil {
194+
spinningSpinner.Stop()
208195
colorlog.PrintErrorAndExit(fmt.Sprintf("ERROR: Running ghorg clone cmd: %v, err: %v", safeToLogCmd, err))
209196
}
210197
}

cmd/root.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ var (
6161
insecureGitlabClient bool
6262
insecureGiteaClient bool
6363
fetchAll bool
64-
ghorgReCloneVerbose bool
6564
ghorgReCloneQuiet bool
6665
ghorgReCloneList bool
6766
ghorgReCloneEnvConfigOnly bool
@@ -150,8 +149,6 @@ func getOrSetDefaults(envVar string) {
150149
os.Setenv(envVar, "false")
151150
case "GHORG_NO_DIR_SIZE":
152151
os.Setenv(envVar, "false")
153-
case "GHORG_RECLONE_VERBOSE":
154-
os.Setenv(envVar, "false")
155152
case "GHORG_RECLONE_ENV_CONFIG_ONLY":
156153
os.Setenv(envVar, "false")
157154
case "GHORG_RECLONE_QUIET":
@@ -246,7 +243,6 @@ func InitConfig() {
246243
getOrSetDefaults("GHORG_INSECURE_GITLAB_CLIENT")
247244
getOrSetDefaults("GHORG_INSECURE_GITEA_CLIENT")
248245
getOrSetDefaults("GHORG_BACKUP")
249-
getOrSetDefaults("GHORG_RECLONE_VERBOSE")
250246
getOrSetDefaults("GHORG_RECLONE_ENV_CONFIG_ONLY")
251247
getOrSetDefaults("GHORG_RECLONE_QUIET")
252248
getOrSetDefaults("GHORG_CONCURRENCY")
@@ -349,7 +345,6 @@ func init() {
349345
cloneCmd.Flags().StringVarP(&githubAppID, "github-app-id", "", "", "GHORG_GITHUB_APP_ID - GitHub App ID, for authenticating with GitHub App")
350346

351347
reCloneCmd.Flags().StringVarP(&ghorgReClonePath, "reclone-path", "", "", "GHORG_RECLONE_PATH - If you want to set a path other than $HOME/.config/ghorg/reclone.yaml for your reclone configuration")
352-
reCloneCmd.Flags().BoolVar(&ghorgReCloneVerbose, "verbose", false, "GHORG_RECLONE_VERBOSE - Verbose logging output")
353348
reCloneCmd.Flags().BoolVar(&ghorgReCloneQuiet, "quiet", false, "GHORG_RECLONE_QUIET - Quiet logging output")
354349
reCloneCmd.Flags().BoolVar(&ghorgReCloneList, "list", false, "Prints reclone commands and optional descriptions to stdout then will exit 0. Does not obsfucate tokens, and is only available as a commandline argument")
355350
reCloneCmd.Flags().BoolVar(&ghorgReCloneEnvConfigOnly, "env-config-only", false, "GHORG_RECLONE_ENV_CONFIG_ONLY - Only use environment variables to set the configuration for all reclones.")

sample-conf.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,6 @@ GHORG_BITBUCKET_USERNAME:
274274
# flag (--reclone-path)
275275
GHORG_RECLONE_PATH:
276276

277-
# Get more verbose logging with reclone command
278-
# flag (--verbose)
279-
GHORG_RECLONE_VERBOSE: false
280-
281277
# Quiet logging output with reclone command
282278
# flag (--quiet)
283279
GHORG_RECLONE_QUIET: false

scripts/github_cloud_integration_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ mv $HOME/.config/ghorg/conf-bak.yaml $HOME/.config/ghorg/conf.yaml
8686
# hack to allow sed to be ran on both mac and ubuntu
8787
sed "s/XTOKEN/${GITHUB_TOKEN}/g" $PWD/scripts/testing_confs/reclone-basic.yaml > $PWD/scripts/testing_confs/updated_reclone.yaml
8888

89-
ghorg reclone --reclone-path=$PWD/scripts/testing_confs/updated_reclone.yaml --verbose
89+
ghorg reclone --reclone-path=$PWD/scripts/testing_confs/updated_reclone.yaml
9090

9191
if [ -e /tmp/testing_reclone_with_tag/$REPO_WITH_TESTING_TOPIC ]
9292
then

0 commit comments

Comments
 (0)