Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added BitBucket Server and Data Center support #455

Merged
merged 6 commits into from
Nov 26, 2023

Conversation

lukefx
Copy link
Contributor

@lukefx lukefx commented Nov 15, 2023

Hi all, this is an initial implementation that works on BitBucket Server and Data Center.

Just enable it on configuration.toml and

git_provider="bitbucket_server"

And:
python cli.py --pr_url https://git.onpreminstanceofbitbucket.com/projects/PROJECT/repos/REPO/pull-requests/1 review

Signed-off-by: Luca Simone <info@lucasimone.info>
@lukefx lukefx changed the title Added BitBucket Server Added BitBucket Server and Data Center support Nov 15, 2023
@lukefx
Copy link
Contributor Author

lukefx commented Nov 15, 2023

/review

Copy link
Contributor

github-actions bot commented Nov 15, 2023

PR Analysis

(review updated until commit 26dc2e9)

  • 🎯 Main theme: Adding support for BitBucket Server and Data Center
  • 📝 PR summary: This PR introduces support for BitBucket Server and Data Center in the application. It includes the implementation of a new BitbucketServerProvider class, the addition of new tests, and updates to the existing code to accommodate the new provider.
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: Yes
  • ⏱️ Estimated effort to review [1-5]: 4, because the PR involves a significant amount of new code, including a new provider class and tests. It also modifies existing code, which requires careful review to ensure compatibility and avoid regression issues.
  • 🔒 Security concerns: No security concerns found

PR Feedback

  • 💡 General suggestions: The PR is well-structured and the new feature is implemented in a separate class, which is good for modularity. However, it would be beneficial to ensure that all methods are properly implemented and that error handling is robust. It's also important to ensure that the new provider integrates well with the existing system.

  • 🤖 Code feedback:

    • relevant file: pr_agent/git_providers/bitbucket_server_provider.py
      suggestion: Consider handling exceptions more specifically in the get_repo_settings method. Currently, a broad Exception is caught which might suppress unrelated errors. [important]
      relevant line: except Exception:

    • relevant file: pr_agent/git_providers/bitbucket_server_provider.py
      suggestion: The remove_comment method is currently a pass-through. If this is intentional (e.g., the provider does not support this operation), consider adding a comment or logging a message to indicate this. [medium]
      relevant line: def remove_comment(self, comment):

    • relevant file: pr_agent/git_providers/bitbucket_server_provider.py
      suggestion: The get_commit_messages method raises a NotImplementedError. If this is a feature that will be implemented in the future, consider adding a TODO comment. If the provider does not support this operation, consider logging a message or handling this case more explicitly. [medium]
      relevant line: def get_commit_messages(self):

    • relevant file: pr_agent/git_providers/bitbucket_server_provider.py
      suggestion: The publish_labels and get_labels methods are currently pass-throughs. If this is because the provider does not support these operations, consider adding comments or logging messages to indicate this. [medium]
      relevant line: def publish_labels(self, pr_types: list):

How to use

Tag me in a comment '@CodiumAI-Agent' and add one of the following commands:
/review [-i]: Request a review of your Pull Request. For an incremental review, which only considers changes since the last review, include the '-i' option.
/describe: Modify the PR title and description based on the contents of the PR.
/improve [--extended]: Suggest improvements to the code in the PR. Extended mode employs several calls, and provides a more thorough feedback.
/ask <QUESTION>: Pose a question about the PR.
/update_changelog: Update the changelog based on the PR's contents.

To edit any configuration parameter from configuration.toml, add --config_path=new_value
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, use the /config command.

@mrT23
Copy link
Collaborator

mrT23 commented Nov 16, 2023

/improve --extended

pr_agent/git_providers/bitbucket_server_provider.py Outdated Show resolved Hide resolved
pr_agent/git_providers/bitbucket_server_provider.py Outdated Show resolved Hide resolved
Comment on lines +212 to +213
pass

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: The 'remove_comment' function is currently a pass-through function. If it's not implemented yet, consider raising a NotImplementedError to indicate this.

Suggested change
pass
def remove_comment(self, comment):
raise NotImplementedError("Remove comment function not implemented yet.")

pr_agent/git_providers/bitbucket_server_provider.py Outdated Show resolved Hide resolved
Comment on lines +346 to +347
pass

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: The 'publish_labels' function is currently a pass-through function. If it's not implemented yet, consider raising a NotImplementedError to indicate this.

Suggested change
pass
def publish_labels(self, pr_types: list):
raise NotImplementedError("Publish labels function not implemented yet.")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wondering if we should change that method and raise an exception when labels are not supported by bitbucket. To me, this sounds better as a pass.
Another way could be to create and raise a NotSupportedException.

lukefx and others added 3 commits November 16, 2023 10:58
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@mrT23
Copy link
Collaborator

mrT23 commented Nov 17, 2023

Hi @lukefx

  1. could you add some lines of documentation to 'BitBucket specific methods', explaining what is BitBucket Server and Data Center, and how to use it in pr-agent ?
    https://github.com/Codium-ai/pr-agent/blob/main/INSTALL.md#run-as-a-bitbucket-pipeline

  2. regarding labels, we do have the check:
    self.git_provider.is_supported("get_labels")
    along the code. if False, we publish labels as comment

@lukefx
Copy link
Contributor Author

lukefx commented Nov 17, 2023

@mrT23 labels as comment is ugly as hell :) and you cannot search for them... This is not useful in any way. I don't know if you've seen that but Bitbucket's server UI is pretty behind and old with the current cloud version.

@mrT23
Copy link
Collaborator

mrT23 commented Nov 17, 2023

@mrT23 labels as comment is ugly as hell :) and you cannot search for them... This is not useful in any way. I don't know if you've seen that but Bitbucket's server UI is pretty behind and old with the current cloud version.

not a separate comment. for example, if you use custom labels, in 'describe', you will have an additional section in the PR header: 'PR custom Lables'.

@lukefx
Copy link
Contributor Author

lukefx commented Nov 17, 2023

ok I will check and modify the code :)

@mrT23
Copy link
Collaborator

mrT23 commented Nov 17, 2023

ok I will check and modify the code :)

i don't think you need to modify for that anything. you do have the 'is_supported' method.

my main request is to add some documentation, otherwise it will be very hard to other people to use this mode

@vaibhavkumar-sf
Copy link

@CodiumAI-Agent /review

@CodiumAI-Agent
Copy link

Persistent review updated to latest commit 26dc2e9

@vaibhavkumar-sf
Copy link

/improve --extended

@vaibhavkumar-sf
Copy link

Preparing review...

@vaibhavkumar-sf
Copy link

Preparing review...

1 similar comment
@vaibhavkumar-sf
Copy link

Preparing review...

@mrT23
Copy link
Collaborator

mrT23 commented Nov 21, 2023

@lukefx can you add a few lines fo documentation, so we can merge this ?

@lukefx
Copy link
Contributor Author

lukefx commented Nov 21, 2023

@lukefx can you add a few lines fo documentation, so we can merge this ?

Yes, I'm on it... I also added the support for webhooks and I will commit it soon. Sorry for the wait

@lukefx
Copy link
Contributor Author

lukefx commented Nov 25, 2023

@mrT23 Please review the doc if is enough...

@mrT23
Copy link
Collaborator

mrT23 commented Nov 26, 2023

@lukefx
looks good. thanks for the contribution 👍

@mrT23 mrT23 merged commit 46d4d04 into Codium-ai:main Nov 26, 2023
yochail pushed a commit to yochail/pr-agent that referenced this pull request Feb 11, 2024
Added BitBucket Server and Data Center support
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.

4 participants