Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4f7c784

Browse filesBrowse files
pyhedgehognejch
andauthored
fix(cli): add ability to escape at-prefixed parameter (python-gitlab#2513)
* fix(cli): Add ability to escape at-prefixed parameter (python-gitlab#2511) --------- Co-authored-by: Nejc Habjan <hab.nejc@gmail.com>
1 parent 7d779c8 commit 4f7c784
Copy full SHA for 4f7c784

File tree

Expand file treeCollapse file tree

3 files changed

+33
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+33
-0
lines changed
Open diff view settings
Collapse file

‎docs/cli-usage.rst‎

Copy file name to clipboardExpand all lines: docs/cli-usage.rst
+11Lines changed: 11 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,17 @@ command line. This is handy for values containing new lines for instance:
305305
EOF
306306
$ gitlab project create --name SuperProject --description @/tmp/description
307307
308+
It you want to explicitly pass an argument starting with ``@``, you can escape it using ``@@``:
309+
310+
.. code-block:: console
311+
312+
$ gitlab project-tag list --project-id somenamespace/myproject
313+
...
314+
name: @at-started-tag
315+
...
316+
$ gitlab project-tag delete --project-id somenamespace/myproject --name '@@at-started-tag'
317+
318+
308319
Enabling shell autocompletion
309320
=============================
310321

Collapse file

‎gitlab/cli.py‎

Copy file name to clipboardExpand all lines: gitlab/cli.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ def _get_parser() -> argparse.ArgumentParser:
272272

273273

274274
def _parse_value(v: Any) -> Any:
275+
if isinstance(v, str) and v.startswith("@@"):
276+
return v[1:]
275277
if isinstance(v, str) and v.startswith("@"):
276278
# If the user-provided value starts with @, we try to read the file
277279
# path provided after @ as the real value. Exit on any error.
Collapse file

‎tests/functional/cli/test_cli_v4.py‎

Copy file name to clipboardExpand all lines: tests/functional/cli/test_cli_v4.py
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,26 @@ def test_create_project_with_values_from_file(gitlab_cli, tmpdir):
562562
assert description in ret.stdout
563563

564564

565+
def test_create_project_with_values_at_prefixed(gitlab_cli, tmpdir):
566+
name = "gitlab-project-at-prefixed"
567+
description = "@at-prefixed"
568+
at_prefixed = f"@{description}"
569+
570+
cmd = [
571+
"-v",
572+
"project",
573+
"create",
574+
"--name",
575+
name,
576+
"--description",
577+
at_prefixed,
578+
]
579+
ret = gitlab_cli(cmd)
580+
581+
assert ret.success
582+
assert description in ret.stdout
583+
584+
565585
def test_create_project_deploy_token(gitlab_cli, project):
566586
name = "project-token"
567587
username = "root"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.