昨天我們知道會 call PRReviewer,PRReviewer
裡面會拿到我們主要的 git_provider, PR URL,程式所用的 language。裡面有一個 run 的 func,很重要地執行整個 review 的 flow,裡面包含了
incremental review
只針對從上次 review 以來的新變更,而不是每次都重新 review 整個PR。以此來加快效率,並專注新變更
如果要求要 incremental review,但是從 git provider 沒有拿到變更,下面會將它排除掉
if self.incremental.is_incremental and hasattr(self.git_provider, "unreviewed_files_set") and not self.git_provider.unreviewed_files_set:
get_logger().info(f"Incremental review is enabled for {self.pr_url} but there are no new files")
previous_review_url = ""
if hasattr(self.git_provider, "previous_review"):
previous_review_url = self.git_provider.previous_review.html_url
if get_settings().config.publish_output:
self.git_provider.publish_comment(f"Incremental Review Skipped\n"
f"No files were changed since the [previous PR Review]({previous_review_url})")
return None
auto_approve
查看
if isinstance(self.args, list) and self.args and self.args[0] == 'auto_approve':
get_logger().info(f'Auto approve flow PR: {self.pr_url} ...')
self.auto_approve_logic()
return None
從 auto_approve_logic 開始追,他先查看設定是否啟用 auto_approve
if get_settings().pr_reviewer.enable_auto_approval:
如果啟用,則獲取 auto_approve 的標準值
maximal_review_effort = get_settings().pr_reviewer.maximal_review_effort
從 label review effort [1-5]: 中找到 effort,如果 maximal_review_effort < 5 則 error 並 comment 不 approve
如果通過,則紀錄並發布 comment
is_auto_approved = self.git_provider.auto_approve()
if is_auto_approved:
get_logger().info("Auto-approved PR")
self.git_provider.publish_comment("Auto-approved PR")
來稍微追一下這是怎麼設定來的
default false
def auto_approve(self) -> bool:
return False
從剛剛 PRreviewer 追
if isinstance(self.args, list) and self.args and self.args[0] == 'auto_approve':
追到上一步
await command2class[action](pr_url, ai_handler=self.ai_handler, args=args).run()