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. 

  1. Create 2 files a.txt, b.txt and committed to Master as part of 1st commit 'A'.
  2. Create a branch, modify file a.txt and commit with commit ID 'C'.
  3. 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"

  4. On the master branch, make a commit to file b.txt (with the commit ID B). The git tree looks something like

    Master ->   A --- B
    branch ->     \ _ _ C
  5. Rebase from master branch
  6. 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

IDcreated_timestampupdated_timestampfrom_hashto_hashis_orphanedto_pathresolved
1creation_timestampupdated_timestampAcfalsea.txtfalse

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

IDcreated_timestampupdated_timestampfrom_hashto_hashis_orphanedto_pathresolved
1creation_timestampupdated_timestampAC (no longer available)truea.txtfalse

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.


最終更新日 2024 年 6 月 3 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.