Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix switch statements and cleanup code #806

Merged
merged 5 commits into from
Jun 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions artifactory/commands/repository/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,7 @@ func getLocalRepoConfKeys(pkgType string) []prompt.Suggest {
optionalKeys := []string{utils.SaveAndExit}
optionalKeys = append(optionalKeys, baseLocalRepoConfKeys...)
switch pkgType {
case Gradle:
case Maven:
case Maven, Gradle:
optionalKeys = append(optionalKeys, mavenGradleLocalRepoConfKeys...)
case Rpm:
optionalKeys = append(optionalKeys, rpmLocalRepoConfKeys...)
Expand All @@ -610,8 +609,7 @@ func getRemoteRepoConfKeys(pkgType, templateType string) []prompt.Suggest {
}
optionalKeys = append(optionalKeys, baseRemoteRepoConfKeys...)
switch pkgType {
case Gradle:
case Maven:
case Maven, Gradle:
optionalKeys = append(optionalKeys, mavenGradleRemoteRepoConfKeys...)
case Cocoapods:
optionalKeys = append(optionalKeys, cocoapodsRemoteRepoConfKeys...)
Expand Down Expand Up @@ -647,8 +645,7 @@ func getVirtualRepoConfKeys(pkgType string) []prompt.Suggest {
optionalKeys := []string{utils.SaveAndExit}
optionalKeys = append(optionalKeys, baseVirtualRepoConfKeys...)
switch pkgType {
case Gradle:
case Maven:
case Maven, Gradle:
optionalKeys = append(optionalKeys, mavenGradleVirtualRepoConfKeys...)
case Nuget:
optionalKeys = append(optionalKeys, nugetVirtualRepoConfKeys...)
Expand Down
13 changes: 5 additions & 8 deletions artifactory/commands/transferfiles/delayedartifactshandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package transferfiles
import (
"encoding/json"
"fmt"
"os"
"path"
"path/filepath"

"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transferfiles/api"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/jfrog/jfrog-client-go/utils/io/content"
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
"github.com/jfrog/jfrog-client-go/utils/log"
"os"
"path"
"path/filepath"
)

var maxDelayedArtifactsInFile = 50000
Expand Down Expand Up @@ -217,11 +218,7 @@ type shouldDelayUpload func(string) bool
// Returns an array of functions to control the order of deployment.
func getDelayUploadComparisonFunctions(packageType string) []shouldDelayUpload {
switch packageType {
case maven:
fallthrough
case gradle:
fallthrough
case ivy:
case maven, gradle, ivy:
return []shouldDelayUpload{func(fileName string) bool {
return filepath.Ext(fileName) == ".pom"
}}
Expand Down
4 changes: 1 addition & 3 deletions general/cisetup/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ func convertBuildCmd(data *CiSetupData) (buildCmd string, err error) {
if err != nil {
return "", err
}
case coreutils.Maven:
fallthrough
case coreutils.Gradle:
case coreutils.Maven, coreutils.Gradle:
buildCmd, err = replaceCmdWithRegexp(data.BuiltTechnology.BuildCmd, mvnGradleRegexp, mvnGradleRegexpReplacement)
if err != nil {
return "", err
Expand Down
25 changes: 3 additions & 22 deletions utils/progressbar/progressbarmng.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ func (bm *ProgressBarMng) newDoubleValueProgressBar(getVal func() (firstNumerato
pb := TasksProgressBar{}
windows := coreutils.IsWindows()
padding, filler := paddingAndFiller(windows)
filter := filterColor(GREEN, windows)
pb.bar = bm.container.New(0,
mpb.BarStyle().Lbound("|").Filler(filter).Tip(filter).Padding(padding).Filler(filler).Refiller("").Rbound("|"),
mpb.BarStyle().Lbound("|").Tip(filler).Padding(padding).Filler(filler).Refiller("").Rbound("|"),
mpb.BarRemoveOnComplete(),
mpb.AppendDecorators(
decor.Name(" "+firstValueLine+": "),
Expand Down Expand Up @@ -216,12 +215,11 @@ func (bm *ProgressBarMng) DoneTask(prog *TasksWithHeadlineProg) {
func (bm *ProgressBarMng) NewTasksProgressBar(totalTasks int64, windows bool, taskType string) *TasksProgressBar {
padding, filler := paddingAndFiller(windows)
pb := &TasksProgressBar{}
filter := filterColor(GREEN, windows)
if taskType == "" {
taskType = "Tasks"
}
pb.bar = bm.container.New(0,
mpb.BarStyle().Lbound("|").Filler(filter).Tip(filter).Padding(padding).Filler(filler).Refiller("").Rbound("|"),
mpb.BarStyle().Lbound("|").Tip(filler).Padding(padding).Filler(filler).Refiller("").Rbound("|"),
mpb.BarRemoveOnComplete(),
mpb.AppendDecorators(
decor.Name(" "+taskType+": "),
Expand All @@ -235,10 +233,9 @@ func (bm *ProgressBarMng) NewTasksProgressBar(totalTasks int64, windows bool, ta
func (bm *ProgressBarMng) newTasksProgressBar(getVal func() (numerator, denominator *int64), headLine string) *TasksProgressBar {
padding, filler := paddingAndFiller(coreutils.IsWindows())
pb := &TasksProgressBar{}
filter := filterColor(GREEN, coreutils.IsWindows())
numerator, denominator := getVal()
pb.bar = bm.container.New(0,
mpb.BarStyle().Lbound("|").Filler(filter).Tip(filter).Padding(padding).Filler(filler).Refiller("").Rbound("|"),
mpb.BarStyle().Lbound("|").Tip(filler).Padding(padding).Filler(filler).Refiller("").Rbound("|"),
mpb.BarRemoveOnComplete(),
mpb.AppendDecorators(
decor.Name(" "+headLine+": "),
Expand Down Expand Up @@ -312,22 +309,6 @@ func (bm *ProgressBarMng) GetLogFile() *os.File {
return bm.logFile
}

func filterColor(color Color, windows bool) (filter string) {
if windows {
filter = "●"
return
}
switch color {
default:
filter = "⬜"
case GREEN:
filter = "🟩"
case WHITE:
filter = "⬜"
}
return
}

func paddingAndFiller(windows bool) (padding, filler string) {
padding = ".."
filler = "●"
Expand Down
Loading