Commit comments are lost in pull request after rebase from master in Bitbucket Datacenter
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Fisheye および Crucible は除く
要約
Comments for commits in the pull request (PR) Diff view are lost after rebase from the master in Bitbucket Datacenter. The comments do appear in the Pull request Overview tab as outdated but not seen in the Diff view.
環境
The solution has been validated in Bitbucket Datacenter 8.9.6 but may be applicable to other versions
診断
The behaviour can be reproduced using the following steps.
- Create 2 files a.txt, b.txt and committed to Master as part of 1st commit 'A'.
- Create a branch, modify file a.txt and commit with commit ID 'C'.
Create a PR from branch b1 to master and add a comment to the file
a.txt.
The comment is associated with source commit "A" and target commit "C"On the master branch, make a commit to file b.txt (with the commit ID
B
). The git tree looks something likeMaster -> A --- B branch -> \ _ _ C
- Rebase from master branch
comment on a file a.txt will disappear after rebase in diff view. After the rebase operation, the git tree looks like
Master -> A --- B branch -> \ _ _ D
原因
The comment is associated with source commit "A" and target commit "C". The entries are stored in bb_comment_thread
table in the database. The comment information created on the file a.txt
is stored in the table as
ID | created_timestamp | updated_timestamp | from_hash | to_hash | is_orphaned | to_path | resolved |
---|---|---|---|---|---|---|---|
1 | creation_timestamp | updated_timestamp | A | c | false | a.txt | false |
With the rebase option, the branch commit is rebased to the tip of the master branch. During the rebase process, the commit history is rewritten. The "C" commit is removed, and the "D" commit is added.
Master -> A --- B
branch -> \ _ _ D
The comment information on the table after the rebase operation looks like
ID | created_timestamp | updated_timestamp | from_hash | to_hash | is_orphaned | to_path | resolved |
---|---|---|---|---|---|---|---|
1 | creation_timestamp | updated_timestamp | A | C (no longer available) | true | a.txt | false |
The to_hash
C is no longer available because of rebase operation, the comment is outdated and is_orphaned
flag is marked true. Since the comment is associated with source commit "A" and target commit "C", and the commit "C" is no longer found, the comment is orphaned and not shown for commit "D". So, we see that the comment as "outdated" in pull request overview tab but not shown in pull request Diff view.
ソリューション
The comment is anchored using the from_hash
and to_hash
. The comment is marked outdated on the remove commit (due to rebase operation) in the PR overview and thus not shown in the Diff view as it's outdated. This behaviour is intentional. The original context is retained on the overview and marked as "Outdated," allowing you to see how the content looked when you added your comment. Still, it has been removed from the diff because the current content of the file isn't in a valid context.
To overcome the problem, avoid a rebase operation that rewrites commit history.