diff --git a/gitbug-java b/gitbug-java index c2315d5..cd6baec 100755 --- a/gitbug-java +++ b/gitbug-java @@ -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 diff --git a/gitbug/bug.py b/gitbug/bug.py index 7d4f832..c1aab15 100644 --- a/gitbug/bug.py +++ b/gitbug/bug.py @@ -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