From ebfc4e5812a9d64322cf78c806f08dc8d73880e4 Mon Sep 17 00:00:00 2001 From: zvecr Date: Thu, 2 Jul 2026 23:13:45 +0100 Subject: [PATCH] Align git helper funcs --- qmk_cli/git.py | 6 +++--- qmk_cli/subcommands/clone.py | 2 +- test/test_git.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/qmk_cli/git.py b/qmk_cli/git.py index fdff836..155e6aa 100644 --- a/qmk_cli/git.py +++ b/qmk_cli/git.py @@ -8,7 +8,7 @@ from milc import cli DEFAULT_UPSTREAM = 'https://github.com/qmk/qmk_firmware' -def git_clone(url, destination, branch): +def git_clone(destination, url, branch): """Add the qmk/qmk_firmware upstream to a qmk_firmware clone.""" git_clone = [ 'git', @@ -44,7 +44,7 @@ def git_set_upstream(destination): git_remote = [ 'git', '-C', - destination, + str(destination), 'remote', 'add', 'upstream', @@ -78,7 +78,7 @@ def git_clone_fork(destination, baseurl, fork, branch, force=False): if force: rmtree(destination) - if not git_clone(url, destination, branch): + if not git_clone(destination, url, branch): return False return git_set_upstream(destination) diff --git a/qmk_cli/subcommands/clone.py b/qmk_cli/subcommands/clone.py index 0715260..43665ae 100644 --- a/qmk_cli/subcommands/clone.py +++ b/qmk_cli/subcommands/clone.py @@ -25,4 +25,4 @@ def clone(cli): cli.log.error('Destination already exists: %s', cli.args.destination) return False - return git_clone(git_url, cli.args.destination, cli.args.branch) + return git_clone(cli.args.destination, git_url, cli.args.branch) diff --git a/test/test_git.py b/test/test_git.py index 2b6e4e1..e0245d6 100644 --- a/test/test_git.py +++ b/test/test_git.py @@ -8,7 +8,7 @@ import qmk_cli.git @patch("qmk_cli.git.subprocess.Popen", side_effect=Exception("foobar")) @patch("qmk_cli.git.cli.log.error") def test_git_clone_except(mock_log_error, mock_popen): - ret = qmk_cli.git.git_clone('https://github.com/qmk/qmk_firmware', '/tmp', 'master') + ret = qmk_cli.git.git_clone('/tmp', 'https://github.com/qmk/qmk_firmware', 'master') assert "Could not run" in str(mock_log_error.call_args_list) assert "Exception:foobar" in str(mock_log_error.call_args_list) @@ -20,7 +20,7 @@ def test_git_clone_logs_output(mock_popen, capsys): type(mock_popen().__enter__()).returncode = PropertyMock(return_value=0) type(mock_popen().__enter__()).stdout = PropertyMock(return_value=['asdf']) - ret = qmk_cli.git.git_clone('https://github.com/qmk/qmk_firmware', '/tmp', 'master') + ret = qmk_cli.git.git_clone('/tmp', 'https://github.com/qmk/qmk_firmware', 'master') captured = capsys.readouterr().out assert 'asdf' in captured @@ -31,7 +31,7 @@ def test_git_clone_logs_output(mock_popen, capsys): def test_git_clone_captures_exit_code(mock_popen): type(mock_popen().__enter__()).returncode = PropertyMock(return_value=1) - ret = qmk_cli.git.git_clone('https://github.com/qmk/qmk_firmware', '/tmp', 'master') + ret = qmk_cli.git.git_clone('/tmp', 'https://github.com/qmk/qmk_firmware', 'master') assert ret is False @@ -95,7 +95,7 @@ def test_git_clone_fork_force(git_set_upstream, git_clone, temp_directory): @pytest.mark.integration def test_git_clone(temp_directory): qmk_firmware = temp_directory / 'qmk_firmware' - ret = qmk_cli.git.git_clone('https://github.com/qmk/qmk_firmware', qmk_firmware.as_posix(), 'master') + ret = qmk_cli.git.git_clone(qmk_firmware.as_posix(), 'https://github.com/qmk/qmk_firmware', 'master') from qmk_cli.helpers import is_qmk_firmware