Last active
January 22, 2019 15:20
git-master-branch-changed-files.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is complementary script to our lint-staged setup. This is a bit of magic, but please bare with me. | |
# This script finds new files during the CI job (compared to the master), and | |
# 1. prints all the files in all commits which are not in the master | |
# 2. sorts them and unique them | |
# 3. we care just for src/*.tsx? | |
# 4. ignore return code of grep :) | |
# http://mywiki.wooledge.org/BashFAQ/105 | |
set -e | |
# During the PR you might have created files and then deleted them in another commit, | |
# those files will be considered as touched so we need to filter them out | |
fileExists() { | |
while IFS= read -r f; do | |
if [ -f $f ]; then | |
echo $f; | |
fi | |
done | |
} | |
git log HEAD --not origin/master --no-merges --name-status --pretty=format: \ | |
| awk '{print $2}' \ | |
| sort -u \ | |
| uniq -u \ | |
| grep '.tsx\?$' \ | |
| grep 'src/' \ | |
| fileExists \ | |
| cat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment