Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions gitbug-java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,24 @@ class GitBugJavaCli(object):
for bug in self.__projects[ppid].get_bugs():
print(bug.bid)

def info(self, bid: str):
"""
Get information about a specific bug in GitBug-Java
"""
# Split bid on the last occurence of "-"
pid, _ = bid.rsplit("-", 1)

# Check the pid and bid exist
if pid not in self.__projects:
raise ValueError(f"Unknown project id {pid}")

project = self.__projects[pid]
bug = project.get_bug(bid)
if bug is None:
raise ValueError(f"Unknown bug id {bid} for project {pid}")

print(bug.info())

def checkout(self, bid: str, workdir: str, fixed: bool = False):
"""
Checkout a specific bug in GitBug-Java
Expand Down
31 changes: 31 additions & 0 deletions gitbug/bug.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,5 +310,36 @@ def flat_failed_tests(runs):
else 1
)

def info(self) -> str:
i = 0 if self.strategy == "FAIL_PASS" else 1
failing_tests = [
test
for test in self.actions_runs[i][0]["tests"]
if test["results"][0]["result"] == "Failure"
]

return f"""
### Bug ID
{self.bid}

### Bug Patch
```diff
{self.bug_patch}
```

### Non-Code Patch
```diff
{self.non_code_patch}
```

### Test Patch
```diff
{self.test_patch}
```

### Failing Tests
{"".join(f"- {test['classname']}#{test['name']}\n\t- {test["results"][0]['type']}\n\t- {test["results"][0]['message']}" for test in failing_tests)}
"""

def __str__(self) -> str:
return self.bid