Skip to content

Commit

Permalink
rocks: '--server' flag now accepts several URL's
Browse files Browse the repository at this point in the history
Changed '--server' flag, so it now accepts several URL's.

Closes #686
  • Loading branch information
better0fdead authored and psergee committed Dec 11, 2023
1 parent 550b7b0 commit eaccb11
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Make cartridge app dependencies less strict.
- `tt connect` auto-completion shows directories and files when there are no
running apps.
- `tt rocks --server` now accepts several URL's.

### Added

Expand Down
14 changes: 13 additions & 1 deletion cli/rocks/rocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,19 @@ func addLuarocksRepoOpts(cliOpts *config.CliOpts, args []string) ([]string, erro

// Check whether rocks repository is specified in tt config.
if cliOpts.Repo != nil && cliOpts.Repo.Rocks != "" {
args = append(args, "--server", cliOpts.Repo.Rocks)
isServerSet := false
for i, opt := range args {
if opt == "--server" {
isServerSet = true
args[i+1] = args[i+1] + " " + cliOpts.Repo.Rocks
} else if strings.HasPrefix(opt, "--server=") {
isServerSet = true
args[i] += " " + cliOpts.Repo.Rocks
}
}
if !isServerSet {
args = append(args, "--server", cliOpts.Repo.Rocks)
}
}

return args, nil
Expand Down
26 changes: 26 additions & 0 deletions cli/rocks/rocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,32 @@ func TestAddLuarocksRepoOpts(t *testing.T) {
[]string{"--only-server", "/other/repo"}, // No --server option is added.
false,
},
{
"Rock repo is specified and --server is passed",
args{
&config.CliOpts{
Repo: &config.RepoOpts{
Rocks: "local_path",
},
},
[]string{"--server", "/other/repo"},
},
[]string{"--server", "/other/repo local_path"},
false,
},
{
"Rock repo is specified and --server= is passed",
args{
&config.CliOpts{
Repo: &config.RepoOpts{
Rocks: "local_path",
},
},
[]string{"--server=/other/repo"},
},
[]string{"--server=/other/repo local_path"},
false,
},
}

for _, tt := range tests {
Expand Down
2 changes: 1 addition & 1 deletion cli/rocks/third_party/luarocks
Submodule luarocks updated 1 files
+8 −3 src/luarocks/cmd.lua

0 comments on commit eaccb11

Please sign in to comment.