Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Travis determine which files changed

Tags:

git

travis-ci

I have a Travis script that runs for every push.

I need to determine which files were modified in this push.

Currently, I have this:

CHANGED_FILES=($(git diff --name-only HEAD HEAD~1))

The problem is that sometimes a push can include more than one commits, and this only looks at the last commit.

What is the expected way to solve this?

like image 235
Nathan H Avatar asked Jul 24 '16 07:07

Nathan H


1 Answers

I found out there is a Travis environment variable: $TRAVIS_COMMIT_RANGE.

Then it was only a matter of changing the script to:

CHANGED_FILES=($(git diff --name-only $TRAVIS_COMMIT_RANGE))

like image 74
Nathan H Avatar answered Oct 02 '22 12:10

Nathan H