|
15 | 15 | ) |
16 | 16 | from lgtm_ai.ai.schemas import AgentSettings, CommentCategory, SupportedAIModelsList |
17 | 17 | from lgtm_ai.base.constants import DEFAULT_HTTPX_TIMEOUT |
| 18 | +from lgtm_ai.base.exceptions import NothingToReviewError |
18 | 19 | from lgtm_ai.base.schemas import IssuesPlatform, LocalRepository, OutputFormat, PRUrl |
19 | 20 | from lgtm_ai.base.utils import git_source_supports_multiline_suggestions |
20 | 21 | from lgtm_ai.config.constants import DEFAULT_INPUT_TOKEN_LIMIT |
@@ -200,12 +201,18 @@ def review(target: PRUrl | LocalRepository, config: str | None, verbose: int, ** |
200 | 201 | git_client=git_client, |
201 | 202 | config=resolved_config, |
202 | 203 | ) |
203 | | - review = code_reviewer.review_pull_request(target=target) |
204 | | - logger.info("Review completed, total comments: %d", len(review.review_response.comments)) |
205 | 204 |
|
| 205 | + formatter, printer = _get_formatter_and_printer(resolved_config.output_format) |
| 206 | + try: |
| 207 | + review = code_reviewer.review(target=target) |
| 208 | + except NothingToReviewError: |
| 209 | + if not resolved_config.silent: |
| 210 | + printer(formatter.empty_review_message()) |
| 211 | + return |
| 212 | + |
| 213 | + logger.info("Review completed, total comments: %d", len(review.review_response.comments)) |
206 | 214 | if not resolved_config.silent: |
207 | 215 | logger.info("Printing review to console") |
208 | | - formatter, printer = _get_formatter_and_printer(resolved_config.output_format) |
209 | 216 | printer(formatter.format_review_summary_section(review)) |
210 | 217 | if review.review_response.comments: |
211 | 218 | printer(formatter.format_review_comments_section(review.review_response.comments)) |
@@ -253,11 +260,18 @@ def guide( |
253 | 260 | git_client=git_client, |
254 | 261 | config=resolved_config, |
255 | 262 | ) |
256 | | - guide = review_guide.generate_review_guide(pr_url=target) |
| 263 | + |
| 264 | + formatter, printer = _get_formatter_and_printer(resolved_config.output_format) |
| 265 | + |
| 266 | + try: |
| 267 | + guide = review_guide.generate_review_guide(pr_url=target) |
| 268 | + except NothingToReviewError: |
| 269 | + if not resolved_config.silent: |
| 270 | + printer(formatter.empty_guide_message()) |
| 271 | + return |
257 | 272 |
|
258 | 273 | if not resolved_config.silent: |
259 | 274 | logger.info("Printing review to console") |
260 | | - formatter, printer = _get_formatter_and_printer(resolved_config.output_format) |
261 | 275 | printer(formatter.format_guide(guide)) |
262 | 276 |
|
263 | 277 | if resolved_config.publish and git_client: |
|
0 commit comments