Running commands against PR branches

Hello all,

I’m essentially trying to run this command:

git diff my-feature..master | xargs eslint

The only issue I have is I need to make master and my-feature variables based on what is setup in the pull request. So essentially running eslint ONLY on the diff between a PR branch and the branch it is attempting to be merged into.

Any ideas?

1 Like

[EDIT] This does not work for PRs containing multiple commits. CIRCLE_COMPARE_URL refers to diffs introduced by a single git push.

You can follow this idea:

Here is a code example:

#CIRCLE_COMPARE_URL=https://github.com/dtprotel/protel360/compare/e8f67d33a268...1d340f4990b5
#Parsing this variable inside circle ci exports.

#Get Commit Ids Part
COMMIT_ID_PARTS=""
IFS='/'
splittedArray=$CIRCLE_COMPARE_URL
for x in $splittedArray
do
    COMMIT_ID_PARTS=$x
done
printf "> Build is between commits : $COMMIT_ID_PARTS\n"

(source NameBright - Coming Soon)