Skip to content

Commit 9f4f4fa

Browse files
committed
Merge remote-tracking branch 'upstream/master' into feature/JFMIG-13
2 parents 15cb578 + f8481d1 commit 9f4f4fa

File tree

12 files changed

+374
-40
lines changed

12 files changed

+374
-40
lines changed

artifactory/commands/transferfiles/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func setRepositoryStatus(stateManager *state.TransferStateManager, output *strin
108108
switch stateManager.CurrentRepoPhase {
109109
case api.Phase1, api.Phase3:
110110
if stateManager.CurrentRepoPhase == api.Phase1 {
111-
addString(output, "🔢", "Phase", "Transferring all files in the repository (1/3)", 3)
111+
addString(output, "🔢", "Phase", "Transferring files in the repository (1/3)", 3)
112112
} else {
113113
addString(output, "🔢", "Phase", "Retrying transfer failures and transfer delayed files (3/3)", 3)
114114
}

artifactory/commands/transferfiles/status_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestShowStatus(t *testing.T) {
7474
// Check repository status
7575
assert.Contains(t, results, "Current Repository Status")
7676
assert.Contains(t, results, "Name: repo1")
77-
assert.Contains(t, results, "Phase: Transferring all files in the repository (1/3)")
77+
assert.Contains(t, results, "Phase: Transferring files in the repository (1/3)")
7878
assert.Contains(t, results, "Visited folders: 15")
7979
assert.Contains(t, results, "Delayed files: 20 (Files to be transferred last, after all other files)")
8080
assert.Contains(t, results, "Storage: 4.9 KiB / 9.8 KiB (50.0%)")

artifactory/commands/transferfiles/transferfileprogress.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/jfrog/jfrog-client-go/utils/errorutils"
1313
)
1414

15-
const phase1HeadLine = "Phase 1: Transferring all files in the repository"
15+
const phase1HeadLine = "Phase 1: Transferring files in the repository"
1616

1717
// TransferProgressMng provides progress indication for the jf rt transfer-files command.
1818
// Transferring one repository's data at a time.

common/cliutils/spec.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package cliutils
22

33
import (
4+
"strconv"
5+
"strings"
6+
47
speccore "github.com/jfrog/jfrog-cli-core/v2/common/spec"
58
"github.com/jfrog/jfrog-cli-core/v2/plugins/components"
69
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
7-
"strconv"
8-
"strings"
910
)
1011

1112
func GetSpec(c *components.Context, isDownload, overrideFieldsIfSet bool) (specFiles *speccore.SpecFiles, err error) {
@@ -58,6 +59,14 @@ func OverrideFieldsIfSet(spec *speccore.File, c *components.Context) {
5859
overrideStringIfSet(&spec.Symlinks, c, "symlinks")
5960
overrideStringIfSet(&spec.Transitive, c, "transitive")
6061
overrideStringIfSet(&spec.PublicGpgKey, c, "gpg-key")
62+
overrideIncludeIfSet(spec, c)
63+
}
64+
65+
// If `include` exist in the cli args, read it to spec.Include as an array split by `;`.
66+
func overrideIncludeIfSet(spec *speccore.File, c *components.Context) {
67+
if c.IsFlagSet("include") {
68+
spec.Include = strings.Split(c.GetStringFlagValue("include"), ";")
69+
}
6170
}
6271

6372
// If `fieldName` exist in the cli args, read it to `field` as a string.

common/commands/curl.go

Lines changed: 89 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,34 +146,107 @@ func (curlCmd *CurlCommand) GetServerDetails() (*config.ServerDetails, error) {
146146
// Use this method ONLY after removing all JFrog-CLI flags, i.e. flags in the form: '--my-flag=value' are not allowed.
147147
// An argument is any provided candidate which is not a flag or a flag value.
148148
func (curlCmd *CurlCommand) findUriValueAndIndex() (int, string) {
149-
skipThisArg := false
149+
// curlBooleanFlags is a set of curl flags that do NOT take a value.
150+
curlBooleanFlags := map[string]struct{}{
151+
"-#": {}, "-:": {}, "-0": {}, "-1": {}, "-2": {}, "-3": {}, "-4": {}, "-6": {},
152+
"-a": {}, "-B": {}, "-f": {}, "-g": {}, "-G": {}, "-I": {}, "-i": {},
153+
"-j": {}, "-J": {}, "-k": {}, "-l": {}, "-L": {}, "-M": {}, "-n": {},
154+
"-N": {}, "-O": {}, "-p": {}, "-q": {}, "-R": {}, "-s": {}, "-S": {},
155+
"-v": {}, "-V": {}, "-Z": {},
156+
"--anyauth": {}, "--append": {}, "--basic": {}, "--ca-native": {},
157+
"--cert-status": {}, "--compressed": {}, "--compressed-ssh": {},
158+
"--create-dirs": {}, "--crlf": {}, "--digest": {}, "--disable": {},
159+
"--disable-eprt": {}, "--disable-epsv": {}, "--disallow-username-in-url": {},
160+
"--doh-cert-status": {}, "--doh-insecure": {}, "--fail": {},
161+
"--fail-early": {}, "--fail-with-body": {}, "--false-start": {},
162+
"--form-escape": {}, "--ftp-create-dirs": {}, "--ftp-pasv": {},
163+
"--ftp-pret": {}, "--ftp-skip-pasv-ip": {}, "--ftp-ssl-ccc": {},
164+
"--ftp-ssl-control": {}, "--get": {}, "--globoff": {},
165+
"--haproxy-protocol": {}, "--head": {}, "--http0.9": {}, "--http1.0": {},
166+
"--http1.1": {}, "--http2": {}, "--http2-prior-knowledge": {},
167+
"--http3": {}, "--http3-only": {}, "--ignore-content-length": {},
168+
"--include": {}, "--insecure": {}, "--ipv4": {}, "--ipv6": {},
169+
"--junk-session-cookies": {}, "--list-only": {}, "--location": {},
170+
"--location-trusted": {}, "--mail-rcpt-allowfails": {}, "--manual": {},
171+
"--metalink": {}, "--negotiate": {}, "--netrc": {}, "--netrc-optional": {},
172+
"--next": {}, "--no-alpn": {}, "--no-buffer": {}, "--no-clobber": {},
173+
"--no-keepalive": {}, "--no-npn": {}, "--no-progress-meter": {},
174+
"--no-sessionid": {}, "--ntlm": {}, "--ntlm-wb": {}, "--parallel": {},
175+
"--parallel-immediate": {}, "--path-as-is": {}, "--post301": {},
176+
"--post302": {}, "--post303": {}, "--progress-bar": {},
177+
"--proxy-anyauth": {}, "--proxy-basic": {}, "--proxy-ca-native": {},
178+
"--proxy-digest": {}, "--proxy-http2": {}, "--proxy-insecure": {},
179+
"--proxy-negotiate": {}, "--proxy-ntlm": {}, "--proxy-ssl-allow-beast": {},
180+
"--proxy-ssl-auto-client-cert": {}, "--proxy-tlsv1": {}, "--proxytunnel": {},
181+
"--raw": {}, "--remote-header-name": {}, "--remote-name": {},
182+
"--remote-name-all": {}, "--remote-time": {}, "--remove-on-error": {},
183+
"--retry-all-errors": {}, "--retry-connrefused": {}, "--sasl-ir": {},
184+
"--show-error": {}, "--silent": {}, "--socks5-basic": {},
185+
"--socks5-gssapi": {}, "--socks5-gssapi-nec": {}, "--ssl": {},
186+
"--ssl-allow-beast": {}, "--ssl-auto-client-cert": {}, "--ssl-no-revoke": {},
187+
"--ssl-reqd": {}, "--ssl-revoke-best-effort": {}, "--sslv2": {},
188+
"--sslv3": {}, "--styled-output": {}, "--suppress-connect-headers": {},
189+
"--tcp-fastopen": {}, "--tcp-nodelay": {}, "--tftp-no-options": {},
190+
"--tlsv1": {}, "--tlsv1.0": {}, "--tlsv1.1": {}, "--tlsv1.2": {},
191+
"--tlsv1.3": {}, "--tr-encoding": {}, "--trace-ids": {},
192+
"--trace-time": {}, "--use-ascii": {}, "--verbose": {}, "--version": {},
193+
"--xattr": {},
194+
}
195+
196+
// isBooleanFlag checks if a flag is in the boolean flags
197+
isBooleanFlag := func(flag string) bool {
198+
_, exists := curlBooleanFlags[flag]
199+
return exists
200+
}
201+
202+
skipNextArg := false
150203
for index, arg := range curlCmd.arguments {
151-
// Check if shouldn't check current arg.
152-
if skipThisArg {
153-
skipThisArg = false
204+
// Check if this arg should be skipped (it's a value for the previous flag)
205+
if skipNextArg {
206+
skipNextArg = false
154207
continue
155208
}
156-
// If starts with '--', meaning a flag which its value is at next slot.
157-
if strings.HasPrefix(arg, "--") {
158-
skipThisArg = true
159-
continue
160-
}
161-
// Check if '-'.
209+
210+
// Check if this is a flag
162211
if strings.HasPrefix(arg, "-") {
163-
if len(arg) > 2 {
164-
// Meaning that this flag also contains its value.
212+
// Check for flags with inline values like --header=value
213+
if strings.HasPrefix(arg, "--") && strings.Contains(arg, "=") {
165214
continue
166215
}
167-
// If reached here, means that the flag value is at the next arg.
168-
skipThisArg = true
216+
217+
// Check if it a boolean flag
218+
if isBooleanFlag(arg) {
219+
continue
220+
}
221+
222+
// For short flags
223+
if !strings.HasPrefix(arg, "--") && len(arg) > 2 {
224+
// find a flag that takes a value, everything after it is the inline value
225+
for i := 1; i < len(arg); i++ {
226+
charFlag := "-" + string(arg[i])
227+
if !isBooleanFlag(charFlag) {
228+
// Found a flag that takes a value
229+
if i < len(arg)-1 {
230+
// Inline value exists (e.g., -XGET, -Lotest.txt)
231+
break
232+
}
233+
// No inline value (e.g., -Lo, -sX), next arg is the value
234+
skipNextArg = true
235+
break
236+
}
237+
}
238+
continue
239+
}
240+
241+
// Flag takes a value in the next argument
242+
skipNextArg = true
169243
continue
170244
}
171245

172-
// Found an argument
246+
// Found a non-flag argument - this is the URL/API path
173247
return index, arg
174248
}
175249

176-
// If reached here, didn't find an argument.
177250
return -1, ""
178251
}
179252

0 commit comments

Comments
 (0)