Files
firefox/python/mozversioncontrol/test/test_push_to_try.py
T
Mike Hommey ee6e08d6dd Bug 1561632 - Back out bug 1554987. r=ahal
Bug 1554987 made `mach try` use a transient remote, but that causes
problems with existing setups that happen to use the same remote name,
because of a combination of not-quite-as-documented-as-it-should
behavior of git.

- `git -c foo.bar=qux` doesn't override the value of `foo.bar` from the
  git configuration when `foo.bar` is an item that can take several
  values.
- `remote.$remote.url` and `remote.$remote.pushurl` take several values,
  allowing to give several URLs.

The combination of both means that if the git configuration already has
`remote.try.url` set, that value takes precedence (because git push
tries them one after the other, and takes the one from the command line
last)

One way we could increase the chances of things working out fine would
be to use `remote.try.pushurl`, which if already set, is more likely to
be right than an existing `remote.try.url`.

OTOH, it turns out, after more investigation, that bug 1554987 requires
a footgunny setup to happen in the first place. Namely, it requires
having run `git lfs install` from a git-cinnabar clone.

so we just go back to the previous status quo.

Differential Revision: https://phabricator.services.mozilla.com/D36149
2019-06-28 15:58:36 +00:00

73 lines
1.9 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 __future__ import absolute_import, unicode_literals
import subprocess
import mozunit
import pytest
from mozversioncontrol import (
get_repository_object,
MissingVCSExtension,
)
def test_push_to_try(repo, monkeypatch):
commit_message = "commit message"
vcs = get_repository_object(repo.strpath)
captured_commands = []
def fake_run(*args, **kwargs):
captured_commands.append(args[0])
monkeypatch.setattr(subprocess, 'check_output', fake_run)
monkeypatch.setattr(subprocess, 'check_call', fake_run)
vcs.push_to_try(commit_message)
tool = vcs._tool
if repo.vcs == 'hg':
expected = [
(tool, 'push-to-try', '-m', commit_message),
(tool, 'revert', '-a'),
]
else:
expected = [
(tool, 'cinnabar', '--version'),
(tool, '-c', 'commit.gpgSign=false', 'commit', '--allow-empty',
'-m', commit_message),
(tool, 'push', 'hg::ssh://hg.mozilla.org/try',
'+HEAD:refs/heads/branches/default/tip'),
(tool, 'reset', 'HEAD~'),
]
for i, value in enumerate(captured_commands):
assert value == expected[i]
assert len(captured_commands) == len(expected)
def test_push_to_try_missing_extensions(repo, monkeypatch):
vcs = get_repository_object(repo.strpath)
orig = vcs._run
def cinnabar_raises(*args, **kwargs):
# Simulate not having git cinnabar
if args[0] == 'cinnabar':
raise subprocess.CalledProcessError(1, args)
return orig(*args, **kwargs)
monkeypatch.setattr(vcs, '_run', cinnabar_raises)
with pytest.raises(MissingVCSExtension):
vcs.push_to_try("commit message")
if __name__ == '__main__':
mozunit.main()