Skip to content

Commit d529ecb

Browse files
committed
Improve upload archive progress bar
Signed-off-by: Michael Sverdlov <[email protected]>
1 parent f326379 commit d529ecb

File tree

3 files changed

+7
-61
lines changed

3 files changed

+7
-61
lines changed

artifactory/commands/dotnet/dotnetcommand.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"net/url"
1616
"os"
1717
"path"
18-
"path/filepath"
1918
"strings"
2019
)
2120

@@ -211,21 +210,6 @@ func RemoveSourceFromNugetConfigIfExists(cmdType dotnet.ToolchainType) error {
211210
return nil
212211
}
213212

214-
// CreateConfigFileIfNeeded creates a new config file if it does not exist.
215-
func CreateConfigFileIfNeeded(customConfigPath string) error {
216-
// Ensure the file exists
217-
exists, err := fileutils.IsFileExists(customConfigPath, false)
218-
if err != nil || exists {
219-
return err
220-
}
221-
// If the file does not exist, create it
222-
if err = os.MkdirAll(filepath.Dir(customConfigPath), 0755); err != nil {
223-
return err
224-
}
225-
// Write the default config content to the file
226-
return os.WriteFile(customConfigPath, []byte("<configuration></configuration>"), 0644)
227-
}
228-
229213
// Checks if the user provided input such as -configfile flag or -Source flag.
230214
// If those flags were provided, NuGet will use the provided configs (default config file or the one with -configfile)
231215
// If neither provided, we are initializing our own config.
@@ -343,6 +327,10 @@ func GetSourceDetails(details *config.ServerDetails, repoName string, useNugetV2
343327
nugetApi = "api/nuget"
344328
}
345329
u.Path = path.Join(u.Path, nugetApi, repoName)
330+
// Append "index.json" for NuGet V3
331+
if !useNugetV2 {
332+
u.Path = path.Join(u.Path, "index.json")
333+
}
346334
sourceURL = u.String()
347335

348336
user = details.User

artifactory/commands/dotnet/dotnetcommand_test.go

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func TestInitNewConfig(t *testing.T) {
8787
assert.Equal(t, `<?xml version="1.0" encoding="utf-8"?>
8888
<configuration>
8989
<packageSources>
90-
<add key="JFrogCli" value="https://server.com/artifactory/api/nuget/v3/test-repo" protocolVersion="3" allowInsecureConnections="true"/>
90+
<add key="JFrogCli" value="https://server.com/artifactory/api/nuget/v3/test-repo/index.json" protocolVersion="3" allowInsecureConnections="true"/>
9191
</packageSources>
9292
<packageSourceCredentials>
9393
<JFrogCli>
@@ -133,7 +133,7 @@ func TestGetSourceDetails(t *testing.T) {
133133
assert.NoError(t, err)
134134
assert.Equal(t, "user", user)
135135
assert.Equal(t, "pass", pass)
136-
assert.Equal(t, "https://server.com/artifactory/api/nuget/v3/repo-name", url)
136+
assert.Equal(t, "https://server.com/artifactory/api/nuget/v3/repo-name/index.json", url)
137137
server.Password = ""
138138
server.AccessToken = "abc123"
139139
url, user, pass, err = GetSourceDetails(server, repoName, true)
@@ -223,45 +223,3 @@ func createNewDotnetModule(t *testing.T, tmpDir string) *build.DotnetModule {
223223
assert.NoError(t, err)
224224
return module
225225
}
226-
227-
func TestCreateConfigFileIfNeeded(t *testing.T) {
228-
testCases := []struct {
229-
name string
230-
configPath string
231-
fileExists bool
232-
expectedError error
233-
}{
234-
{
235-
name: "File does not exist, create file with default content",
236-
configPath: "/custom/path/NuGet.Config",
237-
fileExists: false,
238-
},
239-
{
240-
name: "File exists, no changes",
241-
configPath: "/custom/path/NuGet.Config",
242-
fileExists: true,
243-
},
244-
}
245-
246-
// Setup for testing file existence and creation
247-
for _, testCase := range testCases {
248-
t.Run(testCase.name, func(t *testing.T) {
249-
configPath := filepath.Join(t.TempDir(), testCase.configPath)
250-
if testCase.fileExists {
251-
assert.NoError(t, os.MkdirAll(filepath.Dir(configPath), 0777))
252-
assert.NoError(t, os.WriteFile(configPath, []byte{}, 0644))
253-
}
254-
err := CreateConfigFileIfNeeded(configPath)
255-
assert.NoError(t, err)
256-
257-
if !testCase.fileExists {
258-
// Read the content of the file
259-
content, err := os.ReadFile(configPath)
260-
assert.NoError(t, err)
261-
262-
// Assert the content is the default config content
263-
assert.Equal(t, "<configuration></configuration>", string(content))
264-
}
265-
})
266-
}
267-
}

artifactory/commands/setup/setup_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ func testBuildToolLoginCommandConfigureDotnetNuget(t *testing.T, packageManager
370370

371371
nugetConfigContent := string(nugetConfigContentBytes)
372372

373-
assert.Contains(t, nugetConfigContent, fmt.Sprintf("add key=\"%s\" value=\"https://acme.jfrog.io/artifactory/api/nuget/v3/test-repo\"", dotnet.SourceName))
373+
assert.Contains(t, nugetConfigContent, fmt.Sprintf("add key=\"%s\" value=\"https://acme.jfrog.io/artifactory/api/nuget/v3/test-repo/index.json\"", dotnet.SourceName))
374374

375375
if testCase.accessToken != "" {
376376
// Validate token-based authentication (The token is encoded so we can't test it)

0 commit comments

Comments
 (0)