@@ -89,6 +89,8 @@ def test_multi_file_configuration(tmp_path: Path):
89
89
readme_path .write_text ("MyAwesomeSoftware(TM) v1.0" )
90
90
build_num_path = tmp_path / "BUILD_NUMBER"
91
91
build_num_path .write_text ("1.0.3+joe+38943" )
92
+ csv_path = tmp_path / "Version.csv"
93
+ csv_path .write_text ("1;1;0;3;joe;38943" )
92
94
93
95
overrides = {
94
96
"current_version" : "1.0.3+joe+38943" ,
@@ -115,6 +117,13 @@ def test_multi_file_configuration(tmp_path: Path):
115
117
"filename" : str (build_num_path ),
116
118
"serialize" : ["{major}.{minor}.{patch}+{$USER}+{$BUILD_NUMBER}" ],
117
119
},
120
+ {
121
+ "filename" : str (csv_path ),
122
+ "parse" : r"(?P<major>\d+);(?P<minor>\d+);(?P<patch>\d+);(?P<user>[0-9A-Za-z]+)?;(?P<build_number>[0-9A-Za-z]+)?" ,
123
+ "serialize" : ["{major};{minor};{patch};{$USER};{$BUILD_NUMBER}" ],
124
+ "search" : "1;{current_version}" ,
125
+ "replace" : "1;{new_version}" ,
126
+ },
118
127
],
119
128
}
120
129
conf , version_config , current_version = get_config_data (overrides )
@@ -151,6 +160,77 @@ def test_multi_file_configuration(tmp_path: Path):
151
160
assert maj_vers_path .read_text () == "2"
152
161
assert readme_path .read_text () == "MyAwesomeSoftware(TM) v2.0"
153
162
assert build_num_path .read_text () == "2.0.1+jane+38945"
163
+ assert csv_path .read_text () == "1;2;0;1;jane;38945"
164
+
165
+
166
+ def test_issue_14 (tmp_path : Path ):
167
+ full_vers_path = tmp_path / "FULL_VERSION.txt"
168
+ full_vers_path .write_text ("3.1.0-rc+build.1031" )
169
+ assembly_path = tmp_path / "AssemblyInfo.cs"
170
+ assembly_path .write_text (
171
+ '[assembly: AssemblyFileVersion("3.1.0-rc+build.1031")]\n ' '[assembly: AssemblyVersion("3.1.1031.0")]'
172
+ )
173
+ csv_path = tmp_path / "Version.csv"
174
+ csv_path .write_text ("1;3;1;0;rc;build.1031" )
175
+
176
+ overrides = {
177
+ "current_version" : "3.1.0-rc+build.1031" ,
178
+ "parse" : r"(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-(?P<release>[0-9A-Za-z]+))?(\+build\.(?P<build>.[0-9A-Za-z]+))?" ,
179
+ "serialize" : ["{major}.{minor}.{patch}-{release}+build.{build}" , "{major}.{minor}.{patch}+build.{build}" ],
180
+ "commit" : True ,
181
+ "message" : "Bump version: {current_version} -> {new_version}" ,
182
+ "tag" : False ,
183
+ "tag_name" : "{new_version}" ,
184
+ "tag_message" : "Version {new_version}" ,
185
+ "allow_dirty" : True ,
186
+ "files" : [
187
+ {
188
+ "filename" : str (full_vers_path ),
189
+ },
190
+ {
191
+ "filename" : str (assembly_path ),
192
+ "search" : '[assembly: AssemblyFileVersion("{current_version}")]' ,
193
+ "replace" : '[assembly: AssemblyFileVersion("{new_version}")]' ,
194
+ },
195
+ {
196
+ "filename" : str (assembly_path ),
197
+ "parse" : r"(?P<major>\d+)\.(?P<minor>\d+)\.(?P<build>\d+)\.(?P<patch>\d+)" ,
198
+ "serialize" : ["{major}.{minor}.{build}.{patch}" ],
199
+ "search" : '[assembly: AssemblyVersion("{current_version}")]' ,
200
+ "replace" : '[assembly: AssemblyVersion("{new_version}")]' ,
201
+ },
202
+ {
203
+ "filename" : str (csv_path ),
204
+ "parse" : r"(?P<major>\d+);(?P<minor>\d+);(?P<patch>\d+);(?P<release>[0-9A-Za-z]+)?;(build\.(?P<build>.[0-9A-Za-z]+))?" ,
205
+ "serialize" : [
206
+ "{major};{minor};{patch};{release};build.{build}" ,
207
+ "{major};{minor};{patch};;build.{build}" ,
208
+ ],
209
+ "search" : "1;{current_version}" ,
210
+ "replace" : "1;{new_version}" ,
211
+ },
212
+ ],
213
+ "parts" : {
214
+ "release" : {"values" : ["beta" , "rc" , "final" ], "optional_value" : "final" },
215
+ "build" : {
216
+ "first_value" : 1000 ,
217
+ "independent" : True ,
218
+ },
219
+ },
220
+ }
221
+ conf , version_config , current_version = get_config_data (overrides )
222
+ major_version = current_version .bump ("patch" , version_config .order )
223
+
224
+ ctx = get_context (conf )
225
+
226
+ for file_cfg in conf .files :
227
+ cfg_file = files .ConfiguredFile (file_cfg , version_config )
228
+ cfg_file .replace_version (current_version , major_version , ctx )
229
+
230
+ assert full_vers_path .read_text () == "3.1.1-beta+build.1031"
231
+ expected = '[assembly: AssemblyFileVersion("3.1.1-beta+build.1031")]\n [assembly: AssemblyVersion("3.1.1031.1")]'
232
+ assert assembly_path .read_text () == expected
233
+ assert csv_path .read_text () == "1;3;1;1;beta;build.1031"
154
234
155
235
156
236
def test_search_replace_to_avoid_updating_unconcerned_lines (tmp_path : Path ):
0 commit comments