Add support for the Git-native Firefox repo to `mach try`, by supporting the `base_commit_vcs` field in the Lando-API try push endpoint. Add a new `is_cinnabar_repo` function to `GitRepository` that checks for cinnabar refs in `git for-each-ref`. If the repo is a cinnabar repo, pass the native Git SHA to the Lando try push endpoint and specify the SHA is the `git` vcs. Otherwise, continue with the current behaviour of converting to an hg SHA with `git cinnabar git2hg`, and pass the SHA along as usual. To facilitate the new endpoint, we also update `official_mozilla_remotes` to look for a `https://github.com/mozilla-firefox/firefox` remote, instead of an `hg::https://hg.mozilla.org` remote, when finding the set of remotes to consider "official" for the purposes of identifying the base commit. Differential Revision: https://phabricator.services.mozilla.com/D247030
68 lines
1.7 KiB
Python
68 lines
1.7 KiB
Python
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
from unittest import mock
|
|
|
|
import mozunit
|
|
import pytest
|
|
|
|
from mozversioncontrol import get_repository_object
|
|
|
|
STEPS = {
|
|
"hg": [],
|
|
"git": [
|
|
"git remote add blah https://example.com/blah",
|
|
"""
|
|
git remote add unified hg::https://hg.mozilla.org/mozilla-unified
|
|
git remote add central hg::https://hg.mozilla.org/central
|
|
git remote add try hg::https://hg.mozilla.org/try
|
|
git remote add firefox https://github.com/mozilla-firefox/firefox
|
|
""",
|
|
],
|
|
"jj": [],
|
|
}
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"is_cinnabar,expected_remotes",
|
|
(
|
|
(
|
|
True,
|
|
[
|
|
"--remotes=central",
|
|
"--remotes=unified",
|
|
],
|
|
),
|
|
(False, ["--remotes=firefox"]),
|
|
),
|
|
)
|
|
def test_get_mozilla_remote_args(is_cinnabar, expected_remotes, repo):
|
|
# Test is only relevant for Git.
|
|
if not repo.vcs == "git":
|
|
return
|
|
|
|
repo.execute_next_step()
|
|
|
|
vcs = get_repository_object(repo.dir)
|
|
vcs.is_cinnabar_repo = mock.MagicMock(name="is_cinnabar_repo")
|
|
vcs.is_cinnabar_repo.return_value = is_cinnabar
|
|
|
|
remotes = vcs.get_mozilla_remote_args()
|
|
|
|
assert remotes == [
|
|
"--remotes"
|
|
], "Default `--remotes` passed without finding official remote."
|
|
|
|
repo.execute_next_step()
|
|
|
|
remotes = sorted(vcs.get_mozilla_remote_args())
|
|
|
|
assert (
|
|
remotes == expected_remotes
|
|
), "Multiple non-try remote arguments should be found."
|
|
|
|
|
|
if __name__ == "__main__":
|
|
mozunit.main()
|