How to find all added or removed commits from Pull Request Updates

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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.

*Except Fisheye and Crucible

Summary

After a pull request is created, any updates to the branch will cause the pull request to be updated. If the commits listed are more than 5 the UI will show a number of commits added or removed but not list them.  This should show you all of the activity in that pull request. Here is the process to find all of the commits id's of the commits not listed: 

Solution

Start with the ID of the pull request from the URL.  When viewing URL of the pull request, the pull request id is the number near the end of the URL.  In this example, "pull-requests/96/overview" is the end of the pull request URL, where '86' will be the ID used in the following query:

SELECT activity_id 
FROM   sta_pr_activity 
WHERE  pr_id = 96;

We can then create new queries on sta_pr_rescope_activity based on the specific activity ID returned above. If you include the above query in your where clause, you can create something like:

SELECT * 
FROM   sta_pr_rescope_activity 
WHERE  activity_id IN 
       ( 
              SELECT activity_id 
              FROM   sta_pr_activity 
              WHERE  pr_id = <activity_id> );

Example output:

 activity_id |                from_hash                 |                 to_hash                  |              prev_from_hash              |               prev_to_hash               | commits_added | commits_removed
-------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+---------------+-----------------
        1855 | 5daa180799c9a0ca85e915cb918e8a869c22bba0 | 6158cc2c288e89b8ea1345c8f46bf30d84fb4780 | c36310e6851897dc067599121125d737fab6cd21 | 6158cc2c288e89b8ea1345c8f46bf30d84fb4780 |             1 |               0
        1857 | fa6952ea38d3362da80fef0d8c7d6bbaf4a38835 | 6158cc2c288e89b8ea1345c8f46bf30d84fb4780 | 5daa180799c9a0ca85e915cb918e8a869c22bba0 | 6158cc2c288e89b8ea1345c8f46bf30d84fb4780 |             1 |               0


This shows you all of the activity in the Pull Request.  The number of commits_removed or commits_added to the pull request will help you limit the number of possible hashes used for the next step.  To get the list of commit id's run these two commands from any of the lines returned in the SQL above.  The column names should be replaced with the actual hash below:

git rev-list --ancestry-path <to_hash>..<from_hash>
git rev-list --ancestry-path <prev_to_hash>..<prev_from_hash>




Last modified on Jan 20, 2021

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.