From 9e09726f0c857cac5dc5617bb96a3a646026076a Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Tue, 23 May 2023 17:29:47 +0300 Subject: [PATCH 1/2] Minor code refactoring --- cli/cli.go | 4 ++-- common/alias.json | 9 ++++++--- common/rbinstall.spec | 5 ++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index d8e2da3..f98b7e0 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -66,7 +66,7 @@ import ( // App info const ( APP = "RBInstall" - VER = "3.0.3" + VER = "3.0.4" DESC = "Utility for installing prebuilt Ruby versions to RBEnv" ) @@ -1595,7 +1595,7 @@ func getSystemInfo() (string, string, error) { } if strings.Contains(osInfo.IDLike, "rhel") { - os = fmt.Sprintf("rhel-%d", osVersion.Major()) + os = fmt.Sprintf("el-%d", osVersion.Major()) } else { os = fmt.Sprintf("%s-%d", osInfo.ID, osVersion.Major()) } diff --git a/common/alias.json b/common/alias.json index b5246f1..c9c6b42 100644 --- a/common/alias.json +++ b/common/alias.json @@ -1,5 +1,8 @@ { - "ol-7": "rhel-7", - "ol-8": "rhel-8", - "ol-9": "rhel-9" + "ol-7": "el-7", + "ol-8": "el-8", + "ol-9": "el-9", + "rhel-7": "el-7", + "rhel-8": "el-8", + "rhel-9": "el-9" } diff --git a/common/rbinstall.spec b/common/rbinstall.spec index b1b37c4..8052542 100644 --- a/common/rbinstall.spec +++ b/common/rbinstall.spec @@ -10,7 +10,7 @@ Summary: Utility for installing prebuilt Ruby to rbenv Name: rbinstall -Version: 3.0.3 +Version: 3.0.4 Release: 0%{?dist} Group: Applications/System License: Apache License, Version 2.0 @@ -118,6 +118,9 @@ rm -rf %{buildroot} ################################################################################ %changelog +* Tue May 23 2023 Anton Novojilov - 3.0.4-0 +- Minor code refactoring + * Thu May 18 2023 Anton Novojilov - 3.0.3-0 - [cli] Don't install documentation while updating RubyGems gem - Disable using EK rubygems proxy by default From 9fae6bbae332ca289bcd55fe4df8cbec770dd629 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Tue, 23 May 2023 18:48:49 +0300 Subject: [PATCH 2/2] Fix bug with disabling spinner animation --- cli/cli.go | 14 ++++++++++---- common/rbinstall.spec | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index f98b7e0..bac6694 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -182,6 +182,7 @@ var colorTagApp string var colorTagVer string var useRawOutput = false +var noProgress = false // ////////////////////////////////////////////////////////////////////////////////// // @@ -279,6 +280,11 @@ func configureUI() { progress.DefaultSettings.ProgressColorTag = "{s}" progress.DefaultSettings.SpeedColorTag = "{s}" progress.DefaultSettings.RemainingColorTag = "{s}" + + if os.Getenv("CI") != "" || options.GetB(OPT_NO_PROGRESS) { + spinner.DisableAnimation = true + noProgress = true + } } // prepare do some preparations for installing ruby @@ -671,7 +677,7 @@ func installCommand(rubyVersion string) { spinner.SpinnerColorTag = "{" + categoryColor[category] + "}" fmtc.NameColor("category", "{"+categoryColor[category]+"}") - if !options.GetB(OPT_NO_PROGRESS) { + if !noProgress { fmtc.Printf("Fetching {*}{?category}%s{!} from storage…\n", info.Name) file, err = downloadFile(info) } else { @@ -697,7 +703,7 @@ func installCommand(rubyVersion string) { // //////////////////////////////////////////////////////////////////////////////// // - if !options.GetB(OPT_NO_PROGRESS) { + if !noProgress { fmtc.Printf("Unpacking {*}{?category}%s{!} data…\n", info.Name) err = unpackFile(file, getUnpackDirPath()) } else { @@ -1161,7 +1167,7 @@ func downloadFile(info *index.VersionInfo) (string, error) { return "", fmtc.Errorf("Server return error code %d", resp.StatusCode) } - if options.GetB(OPT_NO_PROGRESS) { + if noProgress { _, err = io.Copy(fd, resp.Body) } else { pb := progress.New(resp.ContentLength, "") @@ -1183,7 +1189,7 @@ func unpackFile(file, outputDir string) error { return fmt.Errorf("Can't unpack %s: %w", file, err) } - if options.GetB(OPT_NO_PROGRESS) { + if noProgress { err = tzst.Read(bufio.NewReader(fd), outputDir) } else { pb := progress.New(fsutil.GetSize(file), "") diff --git a/common/rbinstall.spec b/common/rbinstall.spec index 8052542..723cd25 100644 --- a/common/rbinstall.spec +++ b/common/rbinstall.spec @@ -119,6 +119,7 @@ rm -rf %{buildroot} %changelog * Tue May 23 2023 Anton Novojilov - 3.0.4-0 +- Fixed bug with disabling spinner animation - Minor code refactoring * Thu May 18 2023 Anton Novojilov - 3.0.3-0