I'm looking for a way I can search PR comments to find a discussion.
A few of our senior developers were discussing how we might introduce SccsID-like tagging in our source code so we can identify where code came from.
Unfortunately, the conversation was all inside a PR request, but I'm unsure which of our repos or which of the PRs had the conversation.
So, is there a way to search for them?
Hi Tom,
I'm afraid there is no such built-in feature on our website.
We offer APIs that you can use to retrieve pull request comments and it is possible to search for a string in a PR comment this way, so you could build a script to achieve this.
You can use the following API endpoint to get all repositories in a workspace:
The following API endpoint will return all pull requests in a certain repository:
By default only open pull requests are returned. This can be controlled using the state query parameter. To retrieve pull requests that are in one of multiple states, repeat the state parameter for each individual state.
Then, you can retrieve each PR's comments with the following API endpoint:
If you only want to get PR comments that include the string e.g. sometext, you can adjust the last call as follows:
curl --request GET \
--url 'https://api.bitbucket.org/2.0/repositories/<workspace-id>/<repo>/pullrequests/<PRID>/comments?q=content.raw~"sometext"' \
--header 'Authorization: Bearer <access_token>' \
--header 'Accept: application/json'
If you get results, the output will include the link to the comment, which will show you which repo and which PR it belongs to.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.