Hi, we have the BitBucket Cloud for Slack set up on our Slack channel, and every time I create a new feature branch off of master and push it to the repository, the BitBucket Cloud app message includes way more commits than I would expect. For example:
John Smith pushed 5+ commits to a new branch `feature-branch`
| John Smith
| `ac3478d` Fancy shiny new feature in new branch
| `1b64538` More cleanup in master
| `77de68d` Stuff in master
| `da4b923` Cleanup in master
| `356a192` Old work in master
| repo-name
In other words, even though the feature branch only contains 1 new commit, the new branch message includes all of the old existing 5+ commits from master as well for some reason. Is there a way to make the message only show the new commit(s), and exclude the existing older ones?
Hi Jiayin,
This is actually a pretty interesting problem. Let me break down what's happening as I don't have a bullet proof solution here yet. If you subscribe your Slack channel to both the branch_created and commits_pushed webhooks in Bitbucket then for every new branch created the Bitbucket Slack app will get 2 webhooks.
The branch_created webhook will generate the short form message that just says John Smith created a new branch with the name and a Create Pull Request button.
The commits_pushed webhook will generate the message you posted because Bitbucket pushes up to 5 of the most recent commits to that branch. In the case of a new branch all commits are technically new commits to that branch. As a result you will always see 5+ commits pushed as you illustrated. You can see the details and that Bitbucket calls this out in their API docs here: https://confluence.atlassian.com/bitbucket/event-payloads-740262817.html#EventPayloads-Push
Now that we understand why this is happening we will need to think about what the best way is to fix this. When we receive the commits pushed payload we do have an indication of whether this is happening on a new branch. However, I don't see a way to determine if a commit is a new commit vs an existing commit unfortunately. I will investigate this further and see what our best options are. In an ideal world we should only be displaying commits that are new on this branch rather than any commit that occurred on the branch ever. The only other option I can come up with would be to just suppress the commit pushed message on new branches but some users may find that to be a bug, especially if they don't have the branch created event enabled.
I have opened this issue to track progress on this: https://jira.atlassian.com/browse/API-98 . Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.