| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -482,23 +482,35 @@ def display_dict(d: Dict[str, Any], padding: int) -> None: | |||
| 482 | 482 | if obj._id_attr: | |
| 483 | 483 | attrs.pop(obj._id_attr) | |
| 484 | 484 | display_dict(attrs, padding) | |
| 485 | + return | ||
| 485 | 486 | ||
| 486 | - else: | ||
| 487 | - if TYPE_CHECKING: | ||
| 488 | - assert isinstance(obj, gitlab.base.RESTObject) | ||
| 489 | - if obj._id_attr: | ||
| 490 | - id = getattr(obj, obj._id_attr) | ||
| 491 | - print(f"{obj._id_attr.replace('_', '-')}: {id}") | ||
| 492 | - if obj._repr_attr: | ||
| 493 | - value = getattr(obj, obj._repr_attr, "None") or "None" | ||
| 494 | - value = value.replace("\r", "").replace("\n", " ") | ||
| 495 | - # If the attribute is a note (ProjectCommitComment) then we do | ||
| 496 | - # some modifications to fit everything on one line | ||
| 497 | - line = f"{obj._repr_attr}: {value}" | ||
| 498 | - # ellipsize long lines (comments) | ||
| 499 | - if len(line) > 79: | ||
| 500 | - line = f"{line[:76]}..." | ||
| 501 | - print(line) | ||
| 487 | + lines = [] | ||
| 488 | + | ||
| 489 | + if TYPE_CHECKING: | ||
| 490 | + assert isinstance(obj, gitlab.base.RESTObject) | ||
| 491 | + | ||
| 492 | + if obj._id_attr: | ||
| 493 | + id = getattr(obj, obj._id_attr) | ||
| 494 | + lines.append(f"{obj._id_attr.replace('_', '-')}: {id}") | ||
| 495 | + if obj._repr_attr: | ||
| 496 | + value = getattr(obj, obj._repr_attr, "None") or "None" | ||
| 497 | + value = value.replace("\r", "").replace("\n", " ") | ||
| 498 | + # If the attribute is a note (ProjectCommitComment) then we do | ||
| 499 | + # some modifications to fit everything on one line | ||
| 500 | + line = f"{obj._repr_attr}: {value}" | ||
| 501 | + # ellipsize long lines (comments) | ||
| 502 | + if len(line) > 79: | ||
| 503 | + line = f"{line[:76]}..." | ||
| 504 | + lines.append(line) | ||
| 505 | + | ||
| 506 | + if lines: | ||
| 507 | + print("\n".join(lines)) | ||
| 508 | + return | ||
| 509 | + | ||
| 510 | + print( | ||
| 511 | + f"No default fields to show for {obj!r}. " | ||
| 512 | + f"Please use '--verbose' or the JSON/YAML formatters." | ||
| 513 | + ) | ||
| 502 | 514 | ||
| 503 | 515 | def display_list( | |
| 504 | 516 | self, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -182,3 +182,13 @@ def test_cli_fields_in_list(gitlab_cli, project_file, format, loader): | |||
| 182 | 182 | ||
| 183 | 183 | content = loader(ret.stdout.strip()) | |
| 184 | 184 | assert ["default_branch" in item for item in content] | |
| 185 | + | ||
| 186 | + | ||
| 187 | + def test_cli_display_without_fields_warns(gitlab_cli, project): | ||
| 188 | + cmd = ["project-ci-lint", "get", "--project-id", project.id] | ||
| 189 | + | ||
| 190 | + ret = gitlab_cli(cmd) | ||
| 191 | + assert ret.success | ||
| 192 | + | ||
| 193 | + assert "No default fields to show" in ret.stdout | ||
| 194 | + assert "merged_yaml" not in ret.stdout | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments