Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Detect Revert Commit in pipeline

xicond December 1, 2022

Is There a way to detect Revert action in commit history when running pipeline steps
the worst behave maybe by detecting commit message

I want to clear cache if there's revert action, there's a rare case when revert happen after success packages from composer install being cached but reverted then it use successful cached

1 answer

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 6, 2022

Hi @xicond,

By 'revert action', are you referring to a git revert?

If so, I don't believe there is an automated way to detect this. A revert commit is just a normal commit for Git.

If you standardize your revert commit messages, you could write a script that gets the commit message of the commit that triggered the pipeline and looks for specific words or phrases in order to figure out if it is a revert commit; then use this script in your pipelines build.

You can use any of the following two commands in your Pipelines build to get the message of the commit that triggered the pipeline:

git log -n 1 --pretty=format:%s $BITBUCKET_COMMIT

git show -s --format=%B $BITBUCKET_COMMIT

You would need to make sure in this case that all users who work on this repo use the standard message for revert commits only and not for any other type of commits.

Kind regards,

Suggest an answer

Log in or Sign up to answer
Site Admin
AUG Leaders

Atlassian Community Events