Skip to content

Commit 263d97f

Browse files
committed
feat: utility for showing system information
command to show system info output for bug reports Issue commitizen-tools#426
1 parent d09c085 commit 263d97f

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,18 @@ If applicable, add screenshots to help explain your problem.
2828

2929
## Environment
3030
<!--
31+
For older commitizen versions, please include the
32+
output of the following commands manually:
33+
3134
cz version
3235
python --version
3336
python3 -c "import platform; print(platform.system())"
3437
-->
35-
38+
Add output of the following command to include the following
3639
- commitizen version:
3740
- python version:
3841
- operating system:
42+
```bash
43+
cz version --report
44+
```
45+

commitizen/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@
227227
),
228228
"func": commands.Version,
229229
"arguments": [
230+
{
231+
"name": ["-r", "--report"],
232+
"help": "get system information for reporting bugs",
233+
"action": "store_true",
234+
"exclusive_group": "group1",
235+
},
230236
{
231237
"name": ["-p", "--project"],
232238
"help": "get the version of the current project",

commitizen/commands/version.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import platform
2+
import sys
3+
14
from commitizen import out
25
from commitizen.__version__ import __version__
36
from commitizen.config import BaseConfig
@@ -9,9 +12,15 @@ class Version:
912
def __init__(self, config: BaseConfig, *args):
1013
self.config: BaseConfig = config
1114
self.parameter = args[0]
15+
self.operating_system = platform.system()
16+
self.python_version = sys.version
1217

1318
def __call__(self):
14-
if self.parameter.get("project"):
19+
if self.parameter.get("report"):
20+
out.write(f"Commitizen Version: {__version__}")
21+
out.write(f"Python Version: {self.python_version}")
22+
out.write(f"Operating System: {self.operating_system}")
23+
elif self.parameter.get("project"):
1524
version = self.config.settings["version"]
1625
if version:
1726
out.write(f"{version}")

0 commit comments

Comments
 (0)