From 8a203ccb8b6ba3f4e6e157dabc5266bdc0499470 Mon Sep 17 00:00:00 2001 From: Peter Karakas Date: Thu, 13 Jan 2022 21:58:44 +0100 Subject: [PATCH] Add new global flag to skip artifact upload --- cmd/bitbucket.go | 1 + cmd/local.go | 1 + cmd/root.go | 2 ++ repoSources/repoSource.go | 7 +++++-- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/bitbucket.go b/cmd/bitbucket.go index d993cf0..31a4898 100644 --- a/cmd/bitbucket.go +++ b/cmd/bitbucket.go @@ -34,6 +34,7 @@ var ( Seeds: *RootConfig.Seeds, ShowProgressBar: !*RootConfig.Headless, SkipLibraries: *RootConfig.SkipLibraries, + SkipUpload: *RootConfig.SkipUpload, } err := repoSource.ExtractFromSource(source, config) diff --git a/cmd/local.go b/cmd/local.go index 9a76090..ce65f70 100644 --- a/cmd/local.go +++ b/cmd/local.go @@ -27,6 +27,7 @@ var ( Seeds: *RootConfig.Seeds, ShowProgressBar: !*RootConfig.Headless, SkipLibraries: *RootConfig.SkipLibraries, + SkipUpload: *RootConfig.SkipUpload, } err := repoSource.ExtractFromSource(source, config) diff --git a/cmd/root.go b/cmd/root.go index a4bc027..21511e9 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -18,6 +18,7 @@ type rootConfig struct { OutPutPath *string Obfuscate *bool Headless *bool + SkipUpload *bool } var ( @@ -53,6 +54,7 @@ func init() { RootConfig.OutPutPath = rootCmd.PersistentFlags().String("output_path", "./artifacts", "Where to put output file. Existing artifacts will be overwritten.") RootConfig.Obfuscate = rootCmd.PersistentFlags().Bool("obfuscate", true, "File names and emails won't be hashed. Set it to true for debug purposes.") RootConfig.Headless = rootCmd.PersistentFlags().Bool("headless", false, "Headless mode is used on CodersRank's backend system.") + RootConfig.SkipUpload = rootCmd.PersistentFlags().Bool("skip_upload", false, "Artifacts won't be uploaded. Don't even ask whether to upload the artifacts.") } func initConfig() { diff --git a/repoSources/repoSource.go b/repoSources/repoSource.go index a6c58e9..8fd4a88 100644 --- a/repoSources/repoSource.go +++ b/repoSources/repoSource.go @@ -17,6 +17,7 @@ type ExtractConfig struct { Seeds []string ShowProgressBar bool // Show progress bar only if running in interactive mode SkipLibraries bool + SkipUpload bool // If this is true the artifacts won't be uploaded } // RepoSource describes the interface that each provider has to implement @@ -69,8 +70,10 @@ func ExtractFromSource(source RepoSource, config ExtractConfig) error { } - artifactUploader := NewArtifactUploader(config.OutputPath) - artifactUploader.UploadRepos(repos) + if !config.SkipUpload { + artifactUploader := NewArtifactUploader(config.OutputPath) + artifactUploader.UploadRepos(repos) + } source.CleanUp()