Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Compare Main branch against just merged PR

Ozan Kizildogan January 16, 2025

Migrating from Github Actions to Bitbucket pipelines. We need to use dynamic pipelines to assign the task to self hosted runners.

Is there a Bitbucket API to run the equivalent of below command ? (Or similar trick would work)


git diff @~1 @

The goal is to detect changed file directories and use them to grab the environment and cluster name which are later to be used to pick the right self hosted runner.

1 comment

Comment

Log in or Sign up to comment
Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 16, 2025

Hi @Ozan Kizildogan,

Bitbucket API endpoint for diff is called Compare two commits in the documentation.

The command you're referring to seems to be comparing a commit to its parent, i.e. simply shows the delta of that commit. The equivalent of this operation in terms of Bitbucket API would be the aforementioned endpoint with a spec argument represented by just that single commit.

For example:

https://api.bitbucket.org/2.0/repositories/atlassian/atlassian-spring/diff/48fb8a85d13c7d17f987dea2faec93636fbf8483

From your other post:

I have now another question about comparing the difference between the approved PR against main.

Note that the command you mentioned shows the diff only between the commit and its parent, not necessarily against the main branch of the repo, e.g. if the PR branch has more than one commit it will only show the delta of its tip commit. To get a diff against the main branch, assuming it is called master, add it to the spec like this:

https://api.bitbucket.org/2.0/repositories/atlassian/atlassian-spring/diff/48fb8a85d13c7d17f987dea2faec93636fbf8483..master

Hope this helps.

Cheers,
Daniil

 

Like # people like this
Ozan Kizildogan January 19, 2025

Thanks @Daniil Penkin for the prompt and kind reply.

After trying the API as you suggested, I wasn't successful with the spec piece using the below:

<hash>..<main>. ( we use main instead of master)

However using the hash only for spec also helped.

TAGS
AUG Leaders

Atlassian Community Events