6
6
from bumpversion .config import Config
7
7
from bumpversion .exceptions import BumpVersionError
8
8
from bumpversion .ui import print_info
9
- from bumpversion .utils import get_context
9
+ from bumpversion .utils import base_context , get_context
10
10
11
11
BOX_CHARS = {
12
12
"ascii" : ["+" , "+" , "+" , "+" , "+" , "+" , "+" , "+" , "-" , "|" , "+" ],
@@ -92,10 +92,25 @@ def labeled_line(label: str, border: Border, fit_length: Optional[int] = None) -
92
92
return f" { label } { border .line * (fit_length - len (label ))} { border .line } "
93
93
94
94
95
+ def filter_version_parts (config : Config ) -> list [str ]:
96
+ """
97
+ Return the version parts that are in the configuration.
98
+
99
+ Args:
100
+ config: The configuration to check against
101
+
102
+ Returns:
103
+ The version parts that are in the configuration
104
+ """
105
+ version_parts = [part for part in config .version_config .order if not part .startswith ("$" )]
106
+ default_context = base_context (config .scm_info )
107
+ return [part for part in version_parts if part not in default_context ]
108
+
109
+
95
110
def visualize (config : Config , version_str : str , box_style : str = "light" ) -> None :
96
111
"""Output a visualization of the bump-my-version bump process."""
97
112
version = config .version_config .parse (version_str )
98
- version_parts = config . version_config . order
113
+ version_parts = filter_version_parts ( config )
99
114
num_parts = len (version_parts )
100
115
101
116
box_style = box_style if box_style in BOX_CHARS else "light"
@@ -111,8 +126,8 @@ def visualize(config: Config, version_str: str, box_style: str = "light") -> Non
111
126
try :
112
127
next_version = get_next_version (version , config , part , None )
113
128
next_version_str = config .version_config .serialize (next_version , get_context (config ))
114
- except (BumpVersionError , ValueError ):
115
- next_version_str = "invalid"
129
+ except (BumpVersionError , ValueError ) as e :
130
+ next_version_str = f "invalid: { e } "
116
131
117
132
has_next = i < num_parts - 1
118
133
has_previous = i > 0
0 commit comments