Merge main and complete chat media retirement
This commit is contained in:
@@ -295,7 +295,11 @@ func checkCompatibility(root *cobra.Command, baseline interfaceContract) []strin
|
||||
if expected.RunnableSet && expected.Runnable && !cmd.Runnable() {
|
||||
failures = append(failures, fmt.Sprintf("historical command %q became non-runnable", displayPath(path)))
|
||||
}
|
||||
if expected.HiddenSet && !expected.Hidden && cmd.Hidden {
|
||||
// A hidden, deprecated, still-runnable command is an intentional
|
||||
// compatibility tombstone: it leaves Help without breaking historical
|
||||
// argv. Commands that disappear, stop running, or are hidden without an
|
||||
// actionable deprecation remain compatibility failures.
|
||||
if expected.HiddenSet && !expected.Hidden && cmd.Hidden && !isDeprecatedRunnableTombstone(cmd) {
|
||||
failures = append(failures, fmt.Sprintf("historical command %q became hidden", displayPath(path)))
|
||||
}
|
||||
for _, alias := range sortedSet(expected.Aliases) {
|
||||
@@ -357,6 +361,10 @@ func checkCompatibility(root *cobra.Command, baseline interfaceContract) []strin
|
||||
return failures
|
||||
}
|
||||
|
||||
func isDeprecatedRunnableTombstone(cmd *cobra.Command) bool {
|
||||
return cmd != nil && cmd.Hidden && cmd.Runnable() && strings.TrimSpace(cmd.Deprecated) != ""
|
||||
}
|
||||
|
||||
func resolveCommand(root *cobra.Command, path string) (*cobra.Command, bool) {
|
||||
if path == "root" {
|
||||
return root, true
|
||||
|
||||
@@ -159,6 +159,25 @@ func TestCompatibilityRejectsCommandContractRegressions(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompatibilityAllowsDeprecatedRunnableCommandToBecomeHidden(t *testing.T) {
|
||||
baselineRoot := &cobra.Command{Use: "dws"}
|
||||
baselineRoot.AddCommand(&cobra.Command{Use: "old", Run: func(*cobra.Command, []string) {}})
|
||||
baselineRoot.InitDefaultHelpCmd()
|
||||
baseline := snapshot(baselineRoot)
|
||||
|
||||
currentRoot := &cobra.Command{Use: "dws"}
|
||||
currentRoot.AddCommand(&cobra.Command{
|
||||
Use: "old",
|
||||
Hidden: true,
|
||||
Deprecated: "use dws replacement",
|
||||
Run: func(*cobra.Command, []string) {},
|
||||
})
|
||||
currentRoot.InitDefaultHelpCmd()
|
||||
if failures := checkCompatibility(currentRoot, baseline); len(failures) != 0 {
|
||||
t.Fatalf("deprecated runnable tombstone should be compatible: %v", failures)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompatibilityRejectsFlagContractRegressions(t *testing.T) {
|
||||
newRoot := func(persistent bool) (*cobra.Command, *cobra.Command) {
|
||||
root := &cobra.Command{Use: "dws"}
|
||||
|
||||
Reference in New Issue
Block a user