Skip to content

Feature/gh52 refactor and test review#53

Open
BenjiMilan wants to merge 8 commits intodevelopfrom
feature/gh52_refactor_and_test_review
Open

Feature/gh52 refactor and test review#53
BenjiMilan wants to merge 8 commits intodevelopfrom
feature/gh52_refactor_and_test_review

Conversation

@BenjiMilan
Copy link
Copy Markdown
Contributor

Refactor review for cleanliness and testability and then unittest it.

@BenjiMilan BenjiMilan requested a review from TB-1993 April 28, 2026 14:14
@BenjiMilan BenjiMilan self-assigned this Apr 28, 2026
Copilot AI review requested due to automatic review settings April 28, 2026 14:14
Copy link
Copy Markdown

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

Refactors the sc.review flow into smaller, testable services and shared models, and adds unit tests to validate the new behavior.

Changes:

  • Split responsibilities from Review into TicketService, GitHostService, RepoSource implementations, and Prompter.
  • Consolidated ticket/code-review/comment/repo-info dataclasses into models.py (removing ticket.py and code_review.py).
  • Added new unittest coverage for review execution and key helper behaviors; enhanced run_tests.py to accept a target test directory.

Reviewed changes

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

Show a summary per file
File Description
tests/review/test_ticket_service.py Adds unit tests for TicketService resolve/update/branch matching/prompting.
tests/review/test_review.py Adds unit tests for Review.run() flows and comment aggregation helpers.
tests/review/test_repo_info.py Adds tests for RepoInfo.repo_slug parsing across URL formats.
tests/review/test_git_host_service.py Adds tests for git host matching, instance creation, and CR URL generation.
src/sc/review/ticketing_instances/ticketing_instance.py Updates Ticket import to centralized models.
src/sc/review/ticketing_instances/instances/redmine_instance.py Updates Ticket import to centralized models.
src/sc/review/ticketing_instances/instances/jira_instance.py Updates Ticket import to centralized models.
src/sc/review/ticket_service.py Introduces TicketService for ticket resolution, update, and branch-to-ticket matching.
src/sc/review/ticket.py Removes old Ticket dataclass (moved to models.py).
src/sc/review/review_config.py Splits config into TicketHostConfig/GitHostConfig and corresponding Pydantic models.
src/sc/review/review.py Refactors review workflow to use RepoSource, TicketService, GitHostService, and Prompter.
src/sc/review/repo_source/single_repo_source.py Adds RepoSource for a single git repo.
src/sc/review/repo_source/repo_source.py Adds RepoSource ABC and shared _get_repo_info helper.
src/sc/review/repo_source/manifest_repo_source.py Adds RepoSource for repo manifests and project iteration.
src/sc/review/repo_source/init.py Exposes repo source types from package init.
src/sc/review/prompter.py Adds Prompter wrapper for interactive prompts.
src/sc/review/models.py Adds consolidated dataclasses/enums for tickets, reviews, repo info, and comment rendering.
src/sc/review/main.py Updates CLI entrypoints to use the refactored services/sources/config models.
src/sc/review/git_instances/instances/gitlab_instance.py Updates imports and signature formatting for GitLab instance.
src/sc/review/git_instances/instances/github_instance.py Updates imports and minor formatting for GitHub instance.
src/sc/review/git_instances/git_instance.py Updates base interface types and return contract (`CodeReview
src/sc/review/git_instances/git_factory.py Refactors factory and adds caching to instance creation.
src/sc/review/git_host_service.py Adds GitHostService for git host matching and code review lookups.
src/sc/review/git_flow_branch_strategy.py Adds strategy for computing target branch via git-flow detection.
src/sc/review/code_review.py Removes old CodeReview/CRStatus definitions (moved to models.py).
run_tests.py Allows selecting a test directory via argv (defaults to tests).
Comments suppressed due to low confidence (1)

src/sc/review/git_instances/git_factory.py:32

  • GitFactory.create is missing @classmethod but is called like a factory (GitFactory.create(...)). Without @classmethod, the first argument will bind to the cls parameter incorrectly, breaking provider creation at runtime. Add @classmethod (and ensure @cache wraps the correct callable) so calls bind correctly.
    @cache
    def create(cls, name: str, token: str, base_url: str | None) -> GitInstance:
        try:
            return cls._registry[name.lower()](token=token, base_url=base_url)
        except KeyError:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sc/review/review_config.py
Comment thread tests/review/test_ticket_service.py Outdated
Comment thread src/sc/review/git_instances/instances/gitlab_instance.py
Comment thread src/sc/review/repo_source/manifest_repo_source.py
Comment thread src/sc/review/prompter.py Outdated
Comment thread tests/review/test_ticket_service.py Outdated
Comment thread src/sc/review/repo_source/manifest_repo_source.py
Comment thread src/sc/review/models.py Outdated
Comment thread src/sc/review/git_instances/git_factory.py Outdated
Copilot AI review requested due to automatic review settings May 6, 2026 13:40
@rdkcmf-jenkins
Copy link
Copy Markdown
Contributor

b'## Blackduck scan failure details

Summary: 0 violations, 0 files pending approval, 1 file pending identification.

  • Protex Server Path: /home/blackduck/github/sc/53/rdkcentral/sc

  • Commit: b99a1f3

Report detail: gist'

Copy link
Copy Markdown

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

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

Comment thread src/sc/review/review.py Outdated
Comment thread tests/review/test_review.py Outdated
Comment thread src/sc/review/review_config.py
@rdkcmf-jenkins
Copy link
Copy Markdown
Contributor

b'## WARNING: A Blackduck scan failure has been waived

A prior failure has been upvoted

  • Upvote reason: ok

  • Commit: b99a1f3
    '

Copilot AI review requested due to automatic review settings May 7, 2026 15:12
@BenjiMilan BenjiMilan force-pushed the feature/gh52_refactor_and_test_review branch from d64bef0 to 435b78c Compare May 7, 2026 15:15
Copy link
Copy Markdown

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

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

Comment thread src/sc/review/ticket_service.py
Comment thread src/sc/review/repo_source/manifest_repo_source.py
Comment thread src/sc/review/review_config.py
Comment thread tests/review/test_ticket_updater.py
Copy link
Copy Markdown

@TB-1993 TB-1993 left a comment

Choose a reason for hiding this comment

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

I still have concerns about the structure of this. I feel that a lot of times the top level class is getting a data object, but nothing with it other than passing to another class to do stuff with. So the top level object isn't really the one making the decisions. But I think an SC wide refactor will correct a lot of this.

Comment on lines +31 to +42
def _get_repo_info(self, repo: Repo) -> RepoInfo:
commit = repo.head.commit

return RepoInfo(
branch=repo.active_branch.name,
directory=repo.working_dir,
remote_url=repo.remotes[0].url,
commit_sha=commit.hexsha[:10],
commit_author=f"{commit.author.name} <{commit.author.email}>",
commit_date=commit.committed_datetime,
commit_message=commit.message.strip()
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do you need to use the RepoSource class to get this? Could you not just have the RepoInfo class take a repo object in for itself and set all its attributes?

Comment thread src/sc/review/models.py
Comment on lines +141 to +147
"<pre>",
f"Last Commit: [{self.commit_sha}]",
f"Author: [{self.commit_author}]",
f"Date: [{self.commit_date}]",
"",
f"{self.commit_message}",
"</pre>"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Does this get translated to Jira format?

Comment thread src/sc/review/review.py
logger.info("Enter the ticketing provider from the list below: ")
logger.info("jira")
logger.info("redmine")
provider = input("> ")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I almost think since you have the Prompter class created now it should be used here too.

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.

4 participants