1
0
Fork 0

Adding upstream version 0.16.4.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-11 18:49:40 +01:00
parent 7cdc86fc2c
commit 6e615d8555
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
11 changed files with 143 additions and 124 deletions

View file

@ -8,10 +8,11 @@ def fullpath(fname: str):
return str(TEST_DIR / fname)
PATH_FNAME = fullpath('mock_path_file')
PATH_FNAME_EMPTY = fullpath('empty_path_file')
PATH_FNAME_CLASH = fullpath('clash_path_file')
GROUP_FNAME = fullpath('mock_group_file')
PATH_FNAME = fullpath("mock_path_file")
PATH_FNAME_EMPTY = fullpath("empty_path_file")
PATH_FNAME_CLASH = fullpath("clash_path_file")
GROUP_FNAME = fullpath("mock_group_file")
def async_mock():
"""

View file

@ -4,13 +4,14 @@ from unittest.mock import patch, MagicMock
from gita import info
@patch('subprocess.run')
@patch("subprocess.run")
def test_run_quiet_diff(mock_run):
mock_return = MagicMock()
mock_run.return_value = mock_return
got = info.run_quiet_diff(['--flags'], ['my', 'args'])
got = info.run_quiet_diff(["--flags"], ["my", "args"], "/a/b/c")
mock_run.assert_called_once_with(
['git', '--flags', 'diff', '--quiet', 'my', 'args'],
["git", "--flags", "diff", "--quiet", "my", "args"],
stderr=subprocess.DEVNULL,
cwd="/a/b/c",
)
assert got == mock_return.returncode

View file

@ -71,6 +71,7 @@ class TestLsLl:
"""
functional test
"""
# avoid modifying the local configuration
def side_effect(input, _=None):
return tmp_path / f"{input}.txt"
@ -129,12 +130,12 @@ class TestLsLl:
[
(
PATH_FNAME,
"repo1 cmaster dsu\x1b[0m msg \nrepo2 cmaster dsu\x1b[0m msg \nxxx cmaster dsu\x1b[0m msg \n",
"repo1 cmaster [dsu] \x1b[0m msg \nrepo2 cmaster [dsu] \x1b[0m msg \nxxx cmaster [dsu] \x1b[0m msg \n",
),
(PATH_FNAME_EMPTY, ""),
(
PATH_FNAME_CLASH,
"repo1 cmaster dsu\x1b[0m msg \nrepo2 cmaster dsu\x1b[0m msg \n",
"repo1 cmaster [dsu] \x1b[0m msg \nrepo2 cmaster [dsu] \x1b[0m msg \n",
),
],
)
@ -527,7 +528,9 @@ class TestInfo:
args.info_cmd = None
__main__.f_info(args)
out, err = capfd.readouterr()
assert "In use: branch,commit_msg,commit_time\nUnused: path\n" == out
assert (
"In use: branch,commit_msg,commit_time\nUnused: branch_name,path\n" == out
)
assert err == ""
@patch("gita.common.get_config_fname")

View file

@ -115,17 +115,17 @@ def test_auto_group(repos, paths, expected):
(
[{"abc": {"path": "/root/repo/", "type": "", "flags": []}}, False],
True,
"abc \x1b[31mrepo *+_ \x1b[0m msg xx",
"abc \x1b[31mrepo [*+?] \x1b[0m msg xx",
),
(
[{"abc": {"path": "/root/repo/", "type": "", "flags": []}}, True],
True,
"abc repo *+_ msg xx",
"abc repo [*+?] msg xx",
),
(
[{"repo": {"path": "/root/repo2/", "type": "", "flags": []}}, False],
False,
"repo \x1b[32mrepo _ \x1b[0m msg xx",
"repo \x1b[32mrepo [?] \x1b[0m msg xx",
),
],
)
@ -135,7 +135,7 @@ def test_describe(test_input, diff_return, expected, monkeypatch):
monkeypatch.setattr(info, "get_commit_msg", lambda *_: "msg")
monkeypatch.setattr(info, "get_commit_time", lambda *_: "xx")
monkeypatch.setattr(info, "has_untracked", lambda *_: True)
monkeypatch.setattr("os.chdir", lambda x: None)
monkeypatch.setattr(info, "get_common_commit", lambda x: "")
info.get_color_encoding.cache_clear() # avoid side effect
assert expected == next(utils.describe(*test_input))