Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Comments

Close side panel

polarion_approve_automate() should compare commit hashes to get the git diff.#153

Merged
myakove merged 4 commits intomainRedHatQE/python-utility-scripts:mainfrom
mark_polarionRedHatQE/python-utility-scripts:mark_polarionCopy head branch name to clipboard
Mar 5, 2025
Merged

polarion_approve_automate() should compare commit hashes to get the git diff.#153
myakove merged 4 commits intomainRedHatQE/python-utility-scripts:mainfrom
mark_polarionRedHatQE/python-utility-scripts:mark_polarionCopy head branch name to clipboard

Conversation

@dbasunag
Copy link
Collaborator

@dbasunag dbasunag commented Feb 25, 2025

polarion_approve_automate() is supposed to run on PR submission. The payload generated contains clear information on before and after commit. It is best to compare those. On submission may repos has configuration to delete the branch immediately. We can avoid that issue as well.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced comparison functionality to use commit references. The command-line now requires specifying a previous commit and a current commit instead of a branch.
    • Improved diff processing, enabling comparisons based on specific commit ranges.
  • Tests

    • Introduced a new test for handling missing required parameters, ensuring appropriate error messages are displayed.
    • Updated existing tests to validate functionality with new commit parameters.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2025

Walkthrough

This pull request updates several functions to support commit-based operations rather than branch-based ones. The changes include modifying function signatures in both the Polarion automated and utility modules to accept new parameters for previous and current commits, and adjusting the command-line interface accordingly. Additionally, the git diff functions have been updated to handle either branch or commit inputs, and a new test function has been added to check for missing required parameters.

Changes

Files Change Summary
apps/polarion/{polarion_set_automated.py, polarion_utils.py} Updated function signatures to include optional previous_commit and current_commit parameters; removed or adjusted the branch parameter in the CLI options and git diff logic.
tests/polarion/test_polarion_automated.py Added a new test for missing required parameters; modified existing test to check for specific commit parameters.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4205fb5 and 6840e78.

📒 Files selected for processing (1)
  • apps/polarion/polarion_utils.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/polarion/polarion_utils.py
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: tox
  • GitHub Check: python-module-install

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@redhat-qe-bot1
Copy link
Collaborator

Report bugs in Issues

The following are automatically added:

  • Add reviewers from OWNER file (in the root of the repository) under reviewers section.
  • Set PR size label.
  • New issue is created for the PR. (Closed when PR is merged/closed)
  • Run pre-commit if .pre-commit-config.yaml exists in the repo.

Available user actions:

  • To mark PR as WIP comment /wip to the PR, To remove it from the PR comment /wip cancel to the PR.
  • To block merging of PR comment /hold, To un-block merging of PR comment /hold cancel.
  • To mark PR as verified comment /verified to the PR, to un-verify comment /verified cancel to the PR.
    verified label removed on each new commit push.
  • To cherry pick a merged PR comment /cherry-pick <target branch to cherry-pick to> in the PR.
    • Multiple target branches can be cherry-picked, separated by spaces. (/cherry-pick branch1 branch2)
    • Cherry-pick will be started when PR is merged
  • To build and push container image command /build-and-push-container in the PR (tag will be the PR number).
    • You can add extra args to the Podman build command
      • Example: /build-and-push-container --build-arg OPENSHIFT_PYTHON_WRAPPER_COMMIT=<commit_hash>
  • To add a label by comment use /<label name>, to remove, use /<label name> cancel
  • To assign reviewers based on OWNERS file use /assign-reviewers
  • To check if PR can be merged use /check-can-merge
  • to assign reviewer to PR use /assign-reviewer @<reviewer>
Supported /retest check runs
  • /retest tox: Retest tox
  • /retest python-module-install: Retest python-module-install
  • /retest all: Retest all
Supported labels
  • hold
  • verified
  • wip
  • lgtm

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
apps/polarion/polarion_utils.py (1)

27-29: Minor type annotation inconsistency.

The return type annotation has unnecessary parentheses: (dict)[str, list[str]]. It should be dict[str, list[str]].

-) -> (dict)[str, list[str]]:
+) -> dict[str, list[str]]:
apps/polarion/polarion_set_automated.py (1)

72-77: Inconsistent parameter passing.

This function call doesn't explicitly set branch=None, unlike the call in remove_approved_tests. While functionally equivalent, this inconsistency could affect maintainability.

For consistency with the call on lines 81-86, consider either:

  1. Explicitly setting branch=None here:
 if added_ids := find_polarion_ids(
     polarion_project_id=polarion_project_id,
     string_to_match="added",
+    branch=None,
     previous_commit=previous_commit,
     current_commit=current_commit,
 ):
  1. Or removing the explicit branch=None from the call on lines 81-86 if it's not needed.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff81349 and f7e8808.

📒 Files selected for processing (3)
  • apps/polarion/polarion_set_automated.py (3 hunks)
  • apps/polarion/polarion_utils.py (2 hunks)
  • tests/polarion/test_polarion_automated.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: python-module-install
  • GitHub Check: tox
🔇 Additional comments (4)
tests/polarion/test_polarion_automated.py (1)

17-17: Assertion updated to match new CLI behavior.

The assertion was correctly updated to check for "Missing option" instead of the specific project ID error message, aligning with the CLI changes where both --previous-commit and --current-commit are now required parameters.

apps/polarion/polarion_utils.py (1)

67-73: Enhance flexibility with commit-based operations.

The function signature has been updated to support commit-based operations, which is consistent with the changes in other functions and aligns with the PR objective.

apps/polarion/polarion_set_automated.py (2)

22-28: Function updated to support commit-based operations.

The remove_approved_tests function has been updated to accept both branch-based and commit-based parameters, providing flexibility in how Polarion IDs are retrieved.


81-86: Function call updated to use commit parameters.

The call to remove_approved_tests has been properly updated to pass the commit parameters.

apps/polarion/polarion_utils.py Show resolved Hide resolved
apps/polarion/polarion_set_automated.py Outdated Show resolved Hide resolved
apps/polarion/polarion_set_automated.py Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
apps/polarion/polarion_set_automated.py (1)

55-56: ⚠️ Potential issue

CLI option short form conflict: Both options use the same short form -p.

The --project-id (line 55) and --previous-commit (line 56) both use the same short option -p, which will cause a conflict. Only one of them will be accessible via the short option.

Change one of the short options:

@click.option("--project-id", "-p", help="Provide the polarion project id")
-@click.option("--previous-commit", "-p", help="Provide previous-commit to compare against")
+@click.option("--previous-commit", "-r", help="Provide previous-commit to compare against")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7e8808 and 9bddaa2.

📒 Files selected for processing (3)
  • apps/polarion/polarion_set_automated.py (2 hunks)
  • apps/polarion/polarion_utils.py (2 hunks)
  • tests/polarion/test_polarion_automated.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/polarion/test_polarion_automated.py
  • apps/polarion/polarion_utils.py
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: python-module-install
  • GitHub Check: tox
🔇 Additional comments (4)
apps/polarion/polarion_set_automated.py (4)

59-61: Function signature changed to use commits instead of branch.

The function no longer accepts a branch parameter, which is consistent with the CLI changes but is a breaking change for any code directly calling this function.

Ensure all callers of this function are updated to use commits instead of branch.


98-99: ⚠️ Potential issue

Update the direct call to match the new function signature.

The function call needs to be updated to provide the required parameters according to the new signature.

This direct call will fail since it doesn't provide the required parameters. Consider using Click's standalone mode to make testing easier:

if __name__ == "__main__":
-    polarion_approve_automate()
+    polarion_approve_automate(standalone_mode=False)

Or provide default values in a way that works with Click:

if __name__ == "__main__":
    # Add sys.argv if not present to avoid Click errors
    if len(sys.argv) <= 1:
        sys.argv.extend(["--previous-commit", "HEAD~1", "--current-commit", "HEAD"])
    polarion_approve_automate()

21-28: LGTM: Good backward compatibility for the function signature.

The updated signature for remove_approved_tests maintains backward compatibility by making all parameters optional with sensible defaults, which is a good practice when evolving APIs.


67-68: Good error handling for missing parameters.

The added check for required parameters with a clear error message is a good defensive programming practice.

apps/polarion/polarion_set_automated.py Outdated Show resolved Hide resolved
@dbasunag dbasunag changed the title mark automated can't work with branch with the branch being deleted after PR merge polarion_approve_automate() can't work with branch, instead it should compare commit hash Feb 25, 2025
tests/polarion/test_polarion_automated.py Outdated Show resolved Hide resolved
@myakove
Copy link
Collaborator

myakove commented Feb 26, 2025

can't work with branch, instead it should compare commit hash please explain the issue.

@dbasunag dbasunag changed the title polarion_approve_automate() can't work with branch, instead it should compare commit hash polarion_approve_automate() should compare commit hashes to get the git diff. Feb 26, 2025
@dbasunag
Copy link
Collaborator Author

/verified

apps/polarion/polarion_set_automated.py Show resolved Hide resolved
apps/polarion/polarion_utils.py Show resolved Hide resolved
@dbasunag
Copy link
Collaborator Author

dbasunag commented Mar 3, 2025

/verified

@myakove myakove merged commit 3bd8dd6 into main Mar 5, 2025
5 of 6 checks passed
@myakove myakove deleted the mark_polarion branch March 5, 2025 07:36
@coderabbitai coderabbitai bot mentioned this pull request Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.