Skip to content

Commit

Permalink
update markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
hussam789 committed Mar 10, 2024
1 parent 1cf6d1d commit ff2346e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 6 additions & 2 deletions pr_agent/algo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def unique_strings(input_list: List[str]) -> List[str]:
return unique_list


def convert_to_markdown(output_data: dict, gfm_supported: bool = True) -> str:
def convert_to_markdown(output_data: dict, gfm_supported: bool = True, incremental_review=None) -> str:
"""
Convert a dictionary of data into markdown format.
Args:
Expand All @@ -80,7 +80,11 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool = True) -> str:
"Estimated effort to review [1-5]": "⏱️",
}
markdown_text = ""
markdown_text += f"## PR Review\n\n"
if not incremental_review:
markdown_text += f"## PR Review\n\n"
else:
markdown_text += f"## Incremental PR Review\n\n"
markdown_text += f"⏮️ Review for commits since previous PR-Agent review {incremental_review}.\n\n"
if gfm_supported:
markdown_text += "<table>\n<tr>\n"
# markdown_text += """<td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Feedback&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> <td></td></tr>"""
Expand Down
8 changes: 3 additions & 5 deletions pr_agent/tools/pr_reviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def _prepare_pr_review(self) -> str:
pass


incremental_review_markdown_text = None
# Add incremental review section
if self.incremental.is_incremental:
last_commit_url = f"{self.git_provider.get_pr_url()}/commits/" \
Expand All @@ -216,12 +217,9 @@ def _prepare_pr_review(self) -> str:
if last_commit_msg:
replacement = last_commit_msg.splitlines(keepends=False)[0].replace('_', r'\_')
incremental_review_markdown_text += f" \n_({replacement})_"
data = OrderedDict(data)
data.update({'Incremental PR Review': {
"⏮️ Review for commits since previous PR-Agent review": incremental_review_markdown_text}})
data.move_to_end('Incremental PR Review', last=False)

markdown_text = convert_to_markdown(data, self.git_provider.is_supported("gfm_markdown"))
markdown_text = convert_to_markdown(data, self.git_provider.is_supported("gfm_markdown"),
incremental_review_markdown_text)

# Add help text if gfm_markdown is supported
if self.git_provider.is_supported("gfm_markdown") and get_settings().pr_reviewer.enable_help_text:
Expand Down

0 comments on commit ff2346e

Please sign in to comment.