# Git sha compare ### Idea When committing to a branch, then compare the original master commit of the branch. When committing to master, then compare to the previous master commit. ### Environment variables `CURRENT_SHA = <Codebuild will provide this>` `CURRENT_BRANCH = <Codebuild will provide this>` `ACTUAL_IMAGES_SHA = CURRENT_SHA` `EXPECTED_IMAGES_SHA` ### Logic: ``` if (CURRENT_BRANCH == 'origin/dev') { // Set the expected sha to the last master commit EXPECTED_IMAGES_SHA = git rev-list -n 1 --skip 1 $CURRENT_SHA } else { // Set the expected sha to the original master commit of the branch EXPECTED_IMAGES_SHA = git merge-base origin/dev origin/$CURRENT_BRANCH } ```