| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c6d7e9a commit 3a75d87
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,6 +39,7 @@ def __init__( | |||
| 39 | 39 | self.action = action.lower() | |
| 40 | 40 | self.gl = gl | |
| 41 | 41 | self.args = args | |
| 42 | + self.parent_args = {} | ||
| 42 | 43 | self.mgr_cls: Union[ | |
| 43 | 44 | Type[gitlab.mixins.CreateMixin], | |
| 44 | 45 | Type[gitlab.mixins.DeleteMixin], | |
@@ -53,7 +54,15 @@ def __init__( | |||
| 53 | 54 | # the class _path attribute, and replace the value with the result. | |
| 54 | 55 | if TYPE_CHECKING: | |
| 55 | 56 | assert self.mgr_cls._path is not None | |
| 56 | - self.mgr_cls._path = self.mgr_cls._path.format(**self.args) | ||
| 57 | + # Items in the path need to be url-encoded | ||
| 58 | + if self.mgr_cls._from_parent_attrs: | ||
| 59 | + for k in self.mgr_cls._from_parent_attrs: | ||
| 60 | + if k in self.args: | ||
| 61 | + self.parent_args[k] = gitlab.utils.clean_str_id(self.args[k]) | ||
| 62 | + # If we don't delete it then it will be added to the URL as a | ||
| 63 | + # query-string | ||
| 64 | + del self.args[k] | ||
| 65 | + self.mgr_cls._path = self.mgr_cls._path.format(**self.parent_args) | ||
| 57 | 66 | self.mgr = self.mgr_cls(gl) | |
| 58 | 67 | ||
| 59 | 68 | if self.mgr_cls._types: | |
@@ -85,7 +94,7 @@ def do_custom(self) -> Any: | |||
| 85 | 94 | data = {} | |
| 86 | 95 | if self.mgr._from_parent_attrs: | |
| 87 | 96 | for k in self.mgr._from_parent_attrs: | |
| 88 | - data[k] = self.args[k] | ||
| 97 | + data[k] = self.parent_args[k] | ||
| 89 | 98 | if not issubclass(self.cls, gitlab.mixins.GetWithoutIdMixin): | |
| 90 | 99 | if TYPE_CHECKING: | |
| 91 | 100 | assert isinstance(self.cls._id_attr, str) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,3 +17,10 @@ def test_list_project_variables(gitlab_cli, project): | |||
| 17 | 17 | ret = gitlab_cli(cmd) | |
| 18 | 18 | ||
| 19 | 19 | assert ret.success | |
| 20 | + | ||
| 21 | + | ||
| 22 | + def test_list_project_variables_with_path(gitlab_cli, project): | ||
| 23 | + cmd = ["project-variable", "list", "--project-id", project.path_with_namespace] | ||
| 24 | + ret = gitlab_cli(cmd) | ||
| 25 | + | ||
| 26 | + assert ret.success | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments