Skip to content

Instantly share code, notes, and snippets.

@markburns
Last active August 18, 2017 16:13
Show Gist options
  • Save markburns/2a4188b69d585a62465d55f76374221b to your computer and use it in GitHub Desktop.
Save markburns/2a4188b69d585a62465d55f76374221b to your computer and use it in GitHub Desktop.
useful bash scripts for finding files/changed files/running specs etc
#!/usr/bin/env bash
git rev-parse --abbrev-ref HEAD | tail -2
#!/usr/bin/env bash
while read line
do
dirname $line
done
#!/usr/bin/env bash
while read line
do
if [ -e $line ]
then
echo $line
fi
done < "${1:-/dev/stdin}"
#!/usr/bin/env bash
while read line
do
if [ -d "$line" ]
then
echo "$line"
fi
done < "${1:-/dev/stdin}"
#!/usr/bin/env bash
if [ ! -e .base-branch ]; then
branch=master
else
branch=$(cat .base-branch)
fi
set -o verbose
show-changed-files $branch | grep "\.rb$" | exists | xargs rubocop -a | grep "no offenses detected" || (echo "rubocop failed" && exit 1)
#!/usr/bin/env bash
ls spec/**/*_spec.rb | grep $1 | xargs zeus rspec
#!/usr/bin/env bash
show-changed-files | directory-from-file | sort | uniq
#!/usr/bin/env bash
main=${1:-master}
git diff --name-only $(current-branch) $(git merge-base $(current-branch) $main) | exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment