From 1426c28bf5a1157153dad8767578ac65e5a478ae Mon Sep 17 00:00:00 2001 From: Eric Bishop Date: Thu, 2 Jan 2025 21:53:39 -0600 Subject: [PATCH] fix(files): add optional ref parameter for cli project-file raw (python-gitlab#3032) The ef parameter was removed in python-gitlab v4.8.0. This will add ef back as an optional parameter for the project-file raw cli command. --- gitlab/v4/objects/files.py | 1 + tests/functional/cli/test_cli_files.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/functional/cli/test_cli_files.py diff --git a/gitlab/v4/objects/files.py b/gitlab/v4/objects/files.py index e6ee27ba2..6d410b32e 100644 --- a/gitlab/v4/objects/files.py +++ b/gitlab/v4/objects/files.py @@ -277,6 +277,7 @@ def delete( # type: ignore[override] @cli.register_custom_action( cls_names="ProjectFileManager", required=("file_path",), + optional=("ref",), ) @exc.on_http_error(exc.GitlabGetError) def raw( diff --git a/tests/functional/cli/test_cli_files.py b/tests/functional/cli/test_cli_files.py new file mode 100644 index 000000000..405fbb21b --- /dev/null +++ b/tests/functional/cli/test_cli_files.py @@ -0,0 +1,21 @@ +def test_project_file_raw(gitlab_cli, project, project_file): + cmd = ["project-file", "raw", "--project-id", project.id, "--file-path", "README"] + ret = gitlab_cli(cmd) + assert ret.success + assert "Initial content" in ret.stdout + + +def test_project_file_raw_ref(gitlab_cli, project, project_file): + cmd = [ + "project-file", + "raw", + "--project-id", + project.id, + "--file-path", + "README", + "--ref", + "main", + ] + ret = gitlab_cli(cmd) + assert ret.success + assert "Initial content" in ret.stdout