Skip to content
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed

- Arguments of an internal command are not parsed if it is forced over its existent
external counterpart.

## [2.8.1] - 2025-03-10

The release introduces minor changes in stabilization of `tt connect`
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func InitRoot() {
// External commands must be configured in a special way.
// This is necessary, for example, so that we can pass arguments to these commands.
if len(os.Args) > 1 {
configure.ExternalCmd(rootCmd, &cmdCtx, &modulesInfo, os.Args[1:])
configure.ExternalCmd(rootCmd, &cmdCtx, &modulesInfo, cmdCtx.Cli.ForceInternal, os.Args[1:])
}

// Configure help command.
Expand Down
9 changes: 5 additions & 4 deletions cli/configure/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,17 +438,18 @@ func Cli(cmdCtx *cmdcontext.CmdCtx) error {

// ExternalCmd configures external commands.
func ExternalCmd(rootCmd *cobra.Command, cmdCtx *cmdcontext.CmdCtx,
modulesInfo *modules.ModulesInfo, args []string) {
configureExistsCmd(rootCmd, modulesInfo)
modulesInfo *modules.ModulesInfo, forceInternal bool, args []string) {
configureExistsCmd(rootCmd, modulesInfo, forceInternal)
configureNonExistentCmd(rootCmd, cmdCtx, modulesInfo, args)
}

// configureExistsCmd configures an external commands
// that have internal implementation.
func configureExistsCmd(rootCmd *cobra.Command, modulesInfo *modules.ModulesInfo) {
func configureExistsCmd(rootCmd *cobra.Command, modulesInfo *modules.ModulesInfo,
forceInternal bool) {
for _, cmd := range rootCmd.Commands() {
if _, found := (*modulesInfo)[cmd.CommandPath()]; found {
cmd.DisableFlagParsing = true
cmd.DisableFlagParsing = !forceInternal
}
}
}
Expand Down
24 changes: 17 additions & 7 deletions test/integration/version/test_version.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
import re

from utils import run_command_and_get_output
import utils


def test_version_cmd(tt_cmd, tmp_path):
def check_internal_version_cmd(tt_cmd, tmp_path):
cmd = [tt_cmd, "-I", "version"]
rc, output = run_command_and_get_output(cmd, cwd=tmp_path)
rc, output = utils.run_command_and_get_output(cmd, cwd=tmp_path)
assert rc == 0
assert len(re.findall(r"(\s\d+.\d+.\d+,|\s<unknown>,)", output)) == 1

cmd = [tt_cmd, "-I", "version", "--short"]
rc, output = run_command_and_get_output(cmd, cwd=tmp_path)
rc, output = utils.run_command_and_get_output(cmd, cwd=tmp_path)
assert rc == 0
assert re.match(r"(\d+.\d+.\d+|<unknown>)", output)
assert re.match(r"(\d+.\d+.\d+|<unknown>)$", output)

cmd = [tt_cmd, "-I", "version", "--commit"]
rc, output = run_command_and_get_output(cmd, cwd=tmp_path)
rc, output = utils.run_command_and_get_output(cmd, cwd=tmp_path)
assert rc == 0
assert re.match(r"(\d+.\d+.\d+|<unknown>).\w+", output)

cmd = [tt_cmd, "-I", "version", "--commit", "--short"]
rc, output = run_command_and_get_output(cmd, cwd=tmp_path)
rc, output = utils.run_command_and_get_output(cmd, cwd=tmp_path)
assert rc == 0
assert re.match(r"(\d+.\d+.\d+|<unknown>).\w+", output)


def test_version_cmd(tt_cmd, tmp_path):
check_internal_version_cmd(tt_cmd, tmp_path)


def test_version_internal_over_external(tt_cmd, tmp_path):
utils.create_external_module("version", tmp_path)
utils.create_tt_config(tmp_path, tmp_path)
check_internal_version_cmd(tt_cmd, tmp_path)