| ... |
... |
@@ -194,14 +194,11 @@ class BrowserBranch: |
|
194
|
194
|
)
|
|
195
|
195
|
|
|
196
|
196
|
|
|
197
|
|
-def get_stable_branch(
|
|
198
|
|
- compare_version: BrowserBranch,
|
|
199
|
|
-) -> tuple[BrowserBranch, BrowserBranch | None]:
|
|
|
197
|
+def get_stable_branch(compare_version: BrowserBranch) -> BrowserBranch:
|
|
200
|
198
|
"""Find the most recent stable branch in the origin repository.
|
|
201
|
199
|
|
|
202
|
200
|
:param compare_version: The development branch to compare against.
|
|
203
|
|
- :returns: The stable and legacy branches. If no legacy branch is found,
|
|
204
|
|
- `None` will be returned instead.
|
|
|
201
|
+ :returns: The stable branch.
|
|
205
|
202
|
"""
|
|
206
|
203
|
# We search for build1 tags. These are added *after* the rebase of browser
|
|
207
|
204
|
# commits, so the corresponding branch should contain our strings.
|
| ... |
... |
@@ -218,9 +215,7 @@ def get_stable_branch( |
|
218
|
215
|
fetch_args = ("--depth=1", "--filter=object:type=tag")
|
|
219
|
216
|
git_run(["fetch", *fetch_args, "origin", "tag", tag_glob])
|
|
220
|
217
|
stable_branches = []
|
|
221
|
|
- legacy_branches = []
|
|
222
|
218
|
stable_annotation_regex = re.compile(r"\bstable\b")
|
|
223
|
|
- legacy_annotation_regex = re.compile(r"\blegacy\b")
|
|
224
|
219
|
tag_pattern = re.compile(
|
|
225
|
220
|
rf"^{re.escape(compare_version.prefix)}-[^-]+-[^-]+-[^-]+-build1$"
|
|
226
|
221
|
)
|
| ... |
... |
@@ -230,9 +225,7 @@ def get_stable_branch( |
|
230
|
225
|
):
|
|
231
|
226
|
if not tag_pattern.match(build_tag):
|
|
232
|
227
|
continue
|
|
233
|
|
- is_stable = bool(stable_annotation_regex.search(annotation))
|
|
234
|
|
- is_legacy = bool(legacy_annotation_regex.search(annotation))
|
|
235
|
|
- if not is_stable and not is_legacy:
|
|
|
228
|
+ if not stable_annotation_regex.search(annotation):
|
|
236
|
229
|
continue
|
|
237
|
230
|
try:
|
|
238
|
231
|
# Branch name is the same as the tag, minus "-build1".
|
| ... |
... |
@@ -242,40 +235,30 @@ def get_stable_branch( |
|
242
|
235
|
continue
|
|
243
|
236
|
if branch.prefix != compare_version.prefix:
|
|
244
|
237
|
continue
|
|
245
|
|
- if is_stable:
|
|
246
|
|
- # Stable can be one release version behind.
|
|
247
|
|
- # NOTE: In principle, when switching between versions there may be a
|
|
248
|
|
- # window of time where the development branch has not yet progressed
|
|
249
|
|
- # to the next ".0" release, so has the same browser version as the
|
|
250
|
|
- # stable branch. So we also allow for matching browser versions.
|
|
251
|
|
- # NOTE:
|
|
252
|
|
- # 1. The "Will be unused in" message will not make sense, but we do
|
|
253
|
|
- # not expect string differences in this scenario.
|
|
254
|
|
- # 2. We do not expect this scenario to last for long.
|
|
255
|
|
- release_diff = compare_version.browser_version - branch.browser_version
|
|
256
|
|
- if release_diff < 0.0 or release_diff > 1.0:
|
|
257
|
|
- continue
|
|
258
|
|
- stable_branches.append(branch)
|
|
259
|
|
- elif is_legacy:
|
|
260
|
|
- # Legacy can be arbitrary release versions behind.
|
|
261
|
|
- legacy_branches.append(branch)
|
|
|
238
|
+ # Stable can be one release version behind.
|
|
|
239
|
+ # NOTE: In principle, when switching between versions there may be a
|
|
|
240
|
+ # window of time where the development branch has not yet progressed
|
|
|
241
|
+ # to the next ".0" release, so has the same browser version as the
|
|
|
242
|
+ # stable branch. So we also allow for matching browser versions.
|
|
|
243
|
+ # NOTE:
|
|
|
244
|
+ # 1. The "Will be unused in" message will not make sense, but we do
|
|
|
245
|
+ # not expect string differences in this scenario.
|
|
|
246
|
+ # 2. We do not expect this scenario to last for long.
|
|
|
247
|
+ release_diff = compare_version.browser_version - branch.browser_version
|
|
|
248
|
+ if release_diff < 0.0 or release_diff > 1.0:
|
|
|
249
|
+ continue
|
|
|
250
|
+ stable_branches.append(branch)
|
|
262
|
251
|
|
|
263
|
252
|
if not stable_branches:
|
|
264
|
253
|
raise Exception("No stable build1 branch found")
|
|
265
|
254
|
|
|
266
|
|
- return (
|
|
267
|
|
- # Return the stable branch with the highest version.
|
|
268
|
|
- max(stable_branches),
|
|
269
|
|
- max(legacy_branches) if legacy_branches else None,
|
|
270
|
|
- )
|
|
|
255
|
+ # Return the stable branch with the highest version.
|
|
|
256
|
+ return max(stable_branches)
|
|
271
|
257
|
|
|
272
|
258
|
|
|
273
|
259
|
current_branch = BrowserBranch(args.current_branch, is_head=True)
|
|
274
|
260
|
|
|
275
|
|
-stable_branch, legacy_branch = get_stable_branch(current_branch)
|
|
276
|
|
-
|
|
277
|
|
-if os.environ.get("TRANSLATION_INCLUDE_LEGACY", "") != "true":
|
|
278
|
|
- legacy_branch = None
|
|
|
261
|
+stable_branch = get_stable_branch(current_branch)
|
|
279
|
262
|
|
|
280
|
263
|
files_list = []
|
|
281
|
264
|
|
| ... |
... |
@@ -330,32 +313,6 @@ for file_dict in json.loads(args.files): |
|
330
|
313
|
f"Will be unused in {current_branch.browser_version_name}!",
|
|
331
|
314
|
)
|
|
332
|
315
|
|
|
333
|
|
- if legacy_branch and not file_dict.get("exclude-legacy", False):
|
|
334
|
|
- legacy_file = legacy_branch.get_file(name, where_dirs)
|
|
335
|
|
- if legacy_file is not None and current_file is None and stable_file is None:
|
|
336
|
|
- logger.warning(f"{name} still exists in the legacy branch")
|
|
337
|
|
- elif legacy_file is None:
|
|
338
|
|
- logger.warning(f"{name} does not exist in the legacy branch")
|
|
339
|
|
- elif stable_file is not None and legacy_file.path != stable_file.path:
|
|
340
|
|
- logger.warning(
|
|
341
|
|
- f"{name} has different paths in the stable and legacy branch. "
|
|
342
|
|
- f"{stable_file.path} : {legacy_file.path}"
|
|
343
|
|
- )
|
|
344
|
|
- elif current_file is not None and legacy_file.path != current_file.path:
|
|
345
|
|
- logger.warning(
|
|
346
|
|
- f"{name} has different paths in the current and legacy branch. "
|
|
347
|
|
- f"{current_file.path} : {legacy_file.path}"
|
|
348
|
|
- )
|
|
349
|
|
-
|
|
350
|
|
- content = combine_files(
|
|
351
|
|
- name,
|
|
352
|
|
- content,
|
|
353
|
|
- legacy_file.content,
|
|
354
|
|
- f"Unused in {stable_branch.browser_version_name}!",
|
|
355
|
|
- )
|
|
356
|
|
- elif legacy_branch:
|
|
357
|
|
- logger.info(f"Excluding legacy branch for {name}")
|
|
358
|
|
-
|
|
359
|
316
|
files_list.append({
|
|
360
|
317
|
"name": name,
|
|
361
|
318
|
# If "directory" is unspecified, we place the file directly beneath
|
| ... |
... |
@@ -380,8 +337,5 @@ json_data = { |
|
380
|
337
|
"files": files_list,
|
|
381
|
338
|
}
|
|
382
|
339
|
|
|
383
|
|
-if legacy_branch:
|
|
384
|
|
- json_data["legacy-branch"] = legacy_branch.name
|
|
385
|
|
-
|
|
386
|
340
|
with open(args.outname, "w") as file:
|
|
387
|
341
|
json.dump(json_data, file) |