|
|
|
@ -18,9 +18,12 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
|
import scm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def GIT(test: unittest.TestCase,
|
|
|
|
|
*,
|
|
|
|
|
branchref: str | None = None) -> Iterable[tuple[str, list[str]]]:
|
|
|
|
|
def GIT(
|
|
|
|
|
test: unittest.TestCase,
|
|
|
|
|
*,
|
|
|
|
|
branchref: str | None = None,
|
|
|
|
|
system_config: dict[str, list[str]] | None = None
|
|
|
|
|
) -> Iterable[tuple[str, list[str]]]:
|
|
|
|
|
"""Installs fakes/mocks for scm.GIT so that:
|
|
|
|
|
|
|
|
|
|
* GetBranch will just return a fake branchname starting with the value of
|
|
|
|
@ -28,12 +31,13 @@ def GIT(test: unittest.TestCase,
|
|
|
|
|
* git_new_branch.create_new_branch will be mocked to update the value
|
|
|
|
|
returned by GetBranch.
|
|
|
|
|
|
|
|
|
|
If provided, `system_config` allows you to set the 'system' scoped
|
|
|
|
|
git-config which will be visible as the immutable base configuration layer
|
|
|
|
|
for all git config scopes.
|
|
|
|
|
|
|
|
|
|
NOTE: The dependency on git_new_branch.create_new_branch seems pretty
|
|
|
|
|
circular - this functionality should probably move to scm.GIT?
|
|
|
|
|
"""
|
|
|
|
|
# TODO - add `system_config` - this will be configuration which exists at
|
|
|
|
|
# the 'system installation' level and is immutable.
|
|
|
|
|
|
|
|
|
|
_branchref = [branchref or 'refs/heads/main']
|
|
|
|
|
|
|
|
|
|
global_lock = threading.Lock()
|
|
|
|
@ -45,7 +49,7 @@ def GIT(test: unittest.TestCase,
|
|
|
|
|
patches: list[mock._patch] = [
|
|
|
|
|
mock.patch('scm.GIT._new_config_state',
|
|
|
|
|
side_effect=lambda _: scm.GitConfigStateTest(
|
|
|
|
|
global_lock, global_state)),
|
|
|
|
|
global_lock, global_state, system_state=system_config)),
|
|
|
|
|
mock.patch('scm.GIT.GetBranchRef', side_effect=lambda _: _branchref[0]),
|
|
|
|
|
mock.patch('git_new_branch.create_new_branch', side_effect=_newBranch)
|
|
|
|
|
]
|
|
|
|
|