Skip to content

Commit

Permalink
Bug 1635072 Don't hardcode the file used to query the repo version (#207
Browse files Browse the repository at this point in the history
)

This causes issues with Thunderbird as well as being awkward practice.
  • Loading branch information
srfraser authored May 4, 2020
1 parent b993662 commit 27428d4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
8 changes: 8 additions & 0 deletions treescript/src/treescript/data/treescript_task_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
"merge_old_head"
],
"properties": {
"fetch_version_from": {
"type": "string",
"description": "File path to query for version information, used in tags.",
"default": "browser/config/version.txt",
"examples": [
"browser/config/version.txt"
]
},
"version_files": {
"type": "array",
"items": {
Expand Down
14 changes: 11 additions & 3 deletions treescript/src/treescript/merges.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async def apply_rebranding(config, repo_path, merge_config):
log.info("Rebranding %s to %s", merge_config.get("from_branch"), merge_config.get("to_branch"))

# Must collect this before any bumping.
version = get_version("browser/config/version.txt", repo_path)
version = get_version(core_version_file(merge_config), repo_path)
# Used in file replacements, further down.
format_options = {
"current_major_version": version.major_number,
Expand Down Expand Up @@ -146,6 +146,14 @@ async def preserve_tags(config, repo_path, to_branch):
await run_hg_command(config, "commit", "-m", "Preserve old tags after debusetparents. CLOSED TREE DONTBUILD a=release", repo_path=repo_path)


def core_version_file(merge_config):
"""Determine which file to query for the 'main' version.
In a function to avoid duplication of the default value.
"""
return merge_config.get("fetch_version_from", "browser/config/version.txt")


# do_merge {{{1
async def do_merge(config, task, repo_path):
"""Perform a merge day operation.
Expand Down Expand Up @@ -175,7 +183,7 @@ async def do_merge(config, task, repo_path):

# Used if end_tag is set.
await run_hg_command(config, "up", "-C", to_branch, repo_path=repo_path)
to_fx_major_version = get_version("browser/config/version.txt", repo_path).major_number
to_fx_major_version = get_version(core_version_file(merge_config), repo_path).major_number
base_to_rev = await get_revision(config, repo_path, branch=to_branch)

if from_branch:
Expand All @@ -184,7 +192,7 @@ async def do_merge(config, task, repo_path):

base_tag = merge_config.get("base_tag")
if base_tag:
base_tag = base_tag.format(major_version=get_version("browser/config/version.txt", repo_path).major_number)
base_tag = base_tag.format(major_version=get_version(core_version_file(merge_config), repo_path).major_number)
tag_message = f"No bug - tagging {base_from_rev} with {base_tag} a=release DONTBUILD CLOSED TREE"
await run_hg_command(config, "tag", "-m", tag_message, "-r", base_from_rev, "-f", base_tag, repo_path=repo_path)

Expand Down
7 changes: 7 additions & 0 deletions treescript/tests/test_merges.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,10 @@ async def noop_apply_rebranding(*arguments, **kwargs):
for expected in expected_calls:
assert expected in called_args
assert result == [("https://hg.mozilla.org/mozilla-central", "some_revision")]


@pytest.mark.parametrize(
"merge_config,expected", (({}, "browser/config/version.txt"), ({"fetch_version_from": "some/other/version.txt"}, "some/other/version.txt"))
)
def test_core_version_file(merge_config, expected):
assert merges.core_version_file(merge_config) == expected

0 comments on commit 27428d4

Please sign in to comment.