Skip to content

Commit 93b8d10

Browse files
fastfadingvioletsmergify[bot]
authored andcommitted
fix(client/v2/autocli): prevent duplicate addition of customCommands (#22576)
Co-authored-by: Julien Robert <[email protected]> (cherry picked from commit 685218e)
1 parent adf5e1e commit 93b8d10

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

client/v2/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
5858
### Bug Fixes
5959

6060
* [#21853](https://github.com/cosmos/cosmos-sdk/pull/21853) Fix `*big.Int` unmarshalling in txs.
61+
* [#22576](https://github.com/cosmos/cosmos-sdk/pull/22576) Fix duplicate command addition in `autocli` when custom enhanced command has a different name than module name
6162

6263
## [v2.0.0-beta.5] - 2024-09-18
6364

client/v2/autocli/common.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,16 @@ func (b *Builder) enhanceCommandCommon(
140140

141141
// if we have a custom command use that instead of generating one
142142
if custom, ok := customCmds[moduleName]; ok {
143-
if hasModuleOptions { // check if we need to enhance the existing command
143+
// Custom may not be called the same as its module, so we need to have a separate check here
144+
if subCmd := findSubCommand(cmd, custom.Name()); subCmd != nil {
145+
if hasModuleOptions { // check if we need to enhance the existing command
146+
if err := enhanceCustomCmd(b, subCmd, cmdType, modOpts); err != nil {
147+
return err
148+
}
149+
}
150+
continue
151+
}
152+
if hasModuleOptions { // check if we need to enhance the new command
144153
if err := enhanceCustomCmd(b, custom, cmdType, modOpts); err != nil {
145154
return err
146155
}

0 commit comments

Comments
 (0)