Skip to content

Commit 96dc934

Browse files
authored
feat: add info command (#28)
* feat: add info command * add failing tests to output
1 parent 5be2b8e commit 96dc934

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

gitbug-java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,24 @@ class GitBugJavaCli(object):
129129
for bug in self.__projects[ppid].get_bugs():
130130
print(bug.bid)
131131

132+
def info(self, bid: str):
133+
"""
134+
Get information about a specific bug in GitBug-Java
135+
"""
136+
# Split bid on the last occurence of "-"
137+
pid, _ = bid.rsplit("-", 1)
138+
139+
# Check the pid and bid exist
140+
if pid not in self.__projects:
141+
raise ValueError(f"Unknown project id {pid}")
142+
143+
project = self.__projects[pid]
144+
bug = project.get_bug(bid)
145+
if bug is None:
146+
raise ValueError(f"Unknown bug id {bid} for project {pid}")
147+
148+
print(bug.info())
149+
132150
def checkout(self, bid: str, workdir: str, fixed: bool = False):
133151
"""
134152
Checkout a specific bug in GitBug-Java

gitbug/bug.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,5 +310,36 @@ def flat_failed_tests(runs):
310310
else 1
311311
)
312312

313+
def info(self) -> str:
314+
i = 0 if self.strategy == "FAIL_PASS" else 1
315+
failing_tests = [
316+
test
317+
for test in self.actions_runs[i][0]["tests"]
318+
if test["results"][0]["result"] == "Failure"
319+
]
320+
321+
return f"""
322+
### Bug ID
323+
{self.bid}
324+
325+
### Bug Patch
326+
```diff
327+
{self.bug_patch}
328+
```
329+
330+
### Non-Code Patch
331+
```diff
332+
{self.non_code_patch}
333+
```
334+
335+
### Test Patch
336+
```diff
337+
{self.test_patch}
338+
```
339+
340+
### Failing Tests
341+
{"".join(f"- {test['classname']}#{test['name']}\n\t- {test["results"][0]['type']}\n\t- {test["results"][0]['message']}" for test in failing_tests)}
342+
"""
343+
313344
def __str__(self) -> str:
314345
return self.bid

0 commit comments

Comments
 (0)