From 9052de74e22339e74b428498f8bcfbc94ff913a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Mon, 1 Jul 2024 15:49:04 +0200 Subject: [PATCH 1/2] feat: add info command --- gitbug-java | 18 ++++++++++++++++++ gitbug/bug.py | 21 +++++++++++++++++++++ 2 files changed, 39 insertions(+) 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..f80cf1f 100644 --- a/gitbug/bug.py +++ b/gitbug/bug.py @@ -310,5 +310,26 @@ def flat_failed_tests(runs): else 1 ) + def info(self) -> str: + 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} +``` +""" + def __str__(self) -> str: return self.bid From 9acf90bb8dc742190acd39a6f8a43eff1de80bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Tue, 2 Jul 2024 15:53:25 +0200 Subject: [PATCH 2/2] add failing tests to output --- gitbug/bug.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gitbug/bug.py b/gitbug/bug.py index f80cf1f..c1aab15 100644 --- a/gitbug/bug.py +++ b/gitbug/bug.py @@ -311,6 +311,13 @@ def flat_failed_tests(runs): ) 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} @@ -329,6 +336,9 @@ def info(self) -> str: ```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: