diff options
| author | HiFiPHile <[email protected]> | 2026-09-02 15:34:10 +0200 |
|---|---|---|
| committer | HiFiPHile <[email protected]> | 2026-09-02 15:34:10 +0200 |
| commit | d705b828e2da1eeaceddf6f504cb12778b68a63f (patch) | |
| tree | 638fde9ce89cc1c8bee57fe34c5c8895e2635a74 | |
| parent | 4ef2dcfb4695ec9b3241c0cf48f0d1ab736907c7 (diff) | |
fix issue on existing dependency directory without .gitdocs/worktree-reuse-workflow
Signed-off-by: HiFiPHile <[email protected]>
| -rw-r--r-- | test/hil/test/test_ci_select.py | 23 | ||||
| -rwxr-xr-x | tools/get_deps.py | 7 |
2 files changed, 27 insertions, 3 deletions
diff --git a/test/hil/test/test_ci_select.py b/test/hil/test/test_ci_select.py index 22fbde17b..a43348edc 100644 --- a/test/hil/test/test_ci_select.py +++ b/test/hil/test/test_ci_select.py @@ -2598,5 +2598,28 @@ class TestGetDepsExampleShim(unittest.TestCase): self.assertEqual(r.returncode, 0, r.stderr) +class TestGetDepsExistingDirectory(unittest.TestCase): + def test_directory_without_git_metadata_is_initialized(self): + from tempfile import TemporaryDirectory + from unittest import mock + import get_deps + + with TemporaryDirectory() as top: + dep = pathlib.Path(top, 'lib', 'dep') + dep.mkdir(parents=True) + result = subprocess.CompletedProcess([], 0, stdout=b'parent-head\n') + with mock.patch.object(get_deps, 'TOP', pathlib.Path(top)), \ + mock.patch.dict(get_deps.deps_all, + {'lib/dep': ['https://example.invalid/dep.git', + '0123456789abcdef', 'test']}, + clear=True), \ + mock.patch.object(get_deps, 'run_cmd', return_value=result) as run: + self.assertEqual(get_deps.get_a_dep('lib/dep'), 0) + + commands = [call.args[0] for call in run.call_args_list] + self.assertTrue(commands[0].endswith(' init'), commands) + self.assertFalse(any(' reset --hard' in command for command in commands), commands) + + if __name__ == '__main__': unittest.main(verbosity=1) diff --git a/tools/get_deps.py b/tools/get_deps.py index 12bec4861..4668dac3b 100755 --- a/tools/get_deps.py +++ b/tools/get_deps.py @@ -342,9 +342,10 @@ def get_a_dep(d): p = Path(TOP / d) git_cmd = f"git -C {p}" - # Init git deps if not existed - if not p.exists(): - p.mkdir(parents=True) + # Init git deps if not initialized. Checking only p.exists() lets git -C walk + # up to TinyUSB's repository when an empty dependency directory is present. + if not (p / '.git').exists(): + p.mkdir(parents=True, exist_ok=True) run_cmd(f"{git_cmd} init") run_cmd(f"{git_cmd} remote add origin {url}") head = None |
