Skip to content

Instantly share code, notes, and snippets.

@pat
Last active November 9, 2021 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pat/cb5a6f43ad8c6f1b01453d8ee2598ab5 to your computer and use it in GitHub Desktop.
Save pat/cb5a6f43ad8c6f1b01453d8ee2598ab5 to your computer and use it in GitHub Desktop.
function ruby_files() {
xargs ls -1 2>/dev/null | grep '\.rb$'
}
function spec_files() {
xargs ls -1 2>/dev/null | grep '_spec\.rb$'
}
function uncommitted() {
# first command is staged changes, second is new files and unstaged changes
echo "$(git diff --name-only --cached)\n$(git ls-files --others --exclude-standard --modified)"
}
function branch_changes() {
git diff --name-only main
}
function uncommitted_rubocop() {
uncommitted | ruby_files | xargs bundle exec rubocop
}
function branch_rubocop() {
branch_changes | ruby_files | xargs bundle exec rubocop
}
function uncommitted_rspec() {
bundle exec rspec $(uncommitted | spec_files)
}
function branch_rspec() {
bundle exec rspec $(branch_changes | spec_files)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment