fix: add files to git with force flag

It has been reported that AUR repositories might contain .gitignore,
which prevents PKGBUILD/.SRCINFO/whatever to be added without --force
flag. This commit simply adds force flag for all those operations, which
should be fine, because we don't commit wildcards

Closes #167
This commit is contained in:
arcanis committed 2026-10-17 12:17:40 +03:00
1 parent 0b371b3e77
commit 7f28e47ac4
2 files changed
+17 -3

No files matched your search

@@ -195,7 +195,7 @@ def test_init(sources: Sources, mocker: MockerFixture) -> None:
sources.init(local)
check_output_mock.assert_called_once_with(*sources.git(), "init", "--quiet", "--initial-branch",
sources.DEFAULT_BRANCH, cwd=local, logger=pytest.helpers.anyvar(int))
add_mock.assert_called_once_with(local, "PKGBUILD", ".SRCINFO", "local")
add_mock.assert_called_once_with(local, "PKGBUILD", ".SRCINFO", "local", force=True)
commit_mock.assert_called_once_with(local)
@@ -347,6 +347,17 @@ def test_add_skip(sources: Sources, mocker: MockerFixture) -> None:
check_output_mock.assert_not_called()
def test_add_force(sources: Sources, tmp_path: Path, mocker: MockerFixture) -> None:
"""
must add files to git with --force flag
"""
mocker.patch("pathlib.Path.glob", return_value=[Path("local/1"), Path("local/2")])
check_output_mock = mocker.patch("ahriman.core.build_tools.sources.check_output")
sources.add(Path("local"), "PKGBUILD", force=True)
assert "--force" in check_output_mock.call_args.args
def test_commit(sources: Sources, mocker: MockerFixture) -> None:
"""
must commit changes