Skip to content

Conversation

Perdiga
Copy link
Collaborator

@Perdiga Perdiga commented Jul 16, 2025

No description provided.

@Copilot Copilot AI review requested due to automatic review settings July 16, 2025 23:15
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors Git integration to improve handling of changed files filtering by centralizing Git information in a GitInfo object and fixing issues with Git reference handling.

  • Centralizes Git-related information (repository, commit SHA, refs) in a unified GitInfo object
  • Replaces separate base_ref and target_ref parameters with structured Git information
  • Improves error handling and validation for Git operations

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/codeql_wrapper/infrastructure/git_utils.py Enhanced GitInfo class with new fields and refactored get_git_info method to accept optional parameters
src/codeql_wrapper/domain/use_cases/codeql_analysis_use_case.py Updated changed files detection to use Git info from request object
src/codeql_wrapper/domain/entities/codeql_analysis.py Replaced separate ref parameters with GitInfo object in CodeQLAnalysisRequest
src/codeql_wrapper/cli.py Updated CLI to use GitInfo object and removed target_ref option
pyproject.toml Version bump from 0.2.0-alpha.2 to 0.2.0-alpha.5

repository_path: Path,
base_ref: str = "HEAD~1",
target_ref: str = "HEAD",
base_ref: str,
Copy link
Preview

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing default values from function parameters without providing alternatives could break existing code. Consider providing default values or documenting the breaking change clearly.

Suggested change
base_ref: str,
base_ref: Optional[str] = None,

Copilot uses AI. Check for mistakes.

base_ref: str = "HEAD~1",
target_ref: str = "HEAD",
base_ref: str,
target_ref: str,
Copy link
Preview

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing default values from function parameters without providing alternatives could break existing code. Consider providing default values or documenting the breaking change clearly.

Suggested change
target_ref: str,
target_ref: Optional[str] = None,

Copilot uses AI. Check for mistakes.

except Exception:
logger = get_logger(__name__)

if base_ref is None:
Copy link
Preview

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameters are typed as str but the code checks for None. This creates a type mismatch. Either change the type annotation to Optional[str] or remove the None check.

Copilot uses AI. Check for mistakes.

if base_ref is None:
base_ref = GitUtils._get_current_ref(repository_path)

if target_ref is None:
Copy link
Preview

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameters are typed as str but the code checks for None. This creates a type mismatch. Either change the type annotation to Optional[str] or remove the None check.

Copilot uses AI. Check for mistakes.

Comment on lines 226 to 238
if only_changed_files and not git_info.is_git_repository:
click.echo(
click.style("ERROR:", fg="red", bold=True)
+ " --only-changed-files requires a Git repository"
)
sys.exit(1)

if git_info.base_ref is None:
click.echo(
click.style("ERROR:", fg="red", bold=True)
+ "No base reference provided. Please use --base-ref option to specify it."
)
sys.exit(1)
Copy link
Preview

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This validation occurs unconditionally but should only apply when only_changed_files is True. Moving this check inside the only_changed_files condition would be more appropriate.

Copilot uses AI. Check for mistakes.

@Perdiga Perdiga merged commit 2ecced6 into main Jul 16, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant