feat: Add line link generation in Bitbucket provider and improve markdown formatting in pr_code_suggestions.py and IMRPOVE.md

This commit is contained in:
mrT23
2023-11-26 17:12:02 +02:00
parent 20978402ea
commit b1c374808d
6 changed files with 14 additions and 3 deletions

View File

@ -33,6 +33,14 @@ Under the section 'pr_code_suggestions', the [configuration file](./../pr_agent/
- `max_number_of_calls`: maximum number of chunks. Default is 5.
- `final_clip_factor`: factor to remove suggestions with low confidence. Default is 0.9.
#### summarize mode
- `summarize`: if set to true, the tool will summarize the PR code changes. Default is false.
In this mode, instead of presenting commitable suggestions, the different suggestions will be combined into a single compact instruction, with a significant smaller PR footprint.
For example:
`/improve --pr_code_suggestions.summarize=true`
<kbd><img src=./../pics/improved_summerize_closed.png width="512"></kbd>
<kbd><img src=./../pics/improved_summerize_open.png width="512"></kbd>
#### A note on code suggestions quality

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

View File

@ -228,6 +228,10 @@ class BitbucketProvider(GitProvider):
)
return response
def get_line_link(self, relevant_file: str, relevant_line_start: int, relevant_line_end: int = None) -> str:
link = f"{self.pr_url}/#L{relevant_file}T{relevant_line_start}"
return link
def generate_link_to_relevant_line_number(self, suggestion) -> str:
try:
relevant_file = suggestion['relevant file'].strip('`').strip("'")

View File

@ -501,7 +501,6 @@ class GithubProvider(GitProvider):
return ""
def get_line_link(self, relevant_file: str, relevant_line_start: int, relevant_line_end: int = None) -> str:
sha_file = hashlib.sha256(relevant_file.encode('utf-8')).hexdigest()
if relevant_line_end:

View File

@ -255,9 +255,9 @@ class PRCodeSuggestions:
s['relevant lines end'])
data_markdown += f"\n💡 Suggestion:\n\n**{s['suggestion content']}**\n\n"
if code_snippet_link:
data_markdown += f" File: [{s['relevant file']} ({s['relevant lines start']}-{s['relevant lines end']})]({code_snippet_link})\n"
data_markdown += f" File: [{s['relevant file']} ({s['relevant lines start']}-{s['relevant lines end']})]({code_snippet_link})\n\n"
else:
data_markdown += f"File: {s['relevant file']} ({s['relevant lines start']}-{s['relevant lines end']})\n"
data_markdown += f"File: {s['relevant file']} ({s['relevant lines start']}-{s['relevant lines end']})\n\n"
if self.git_provider.is_supported("gfm_markdown"):
data_markdown += "<details> <summary> Example code:</summary>\n\n"
data_markdown += f"___\n\n"