Created
March 30, 2022 16:50
-
-
Save ayaz-ac/177f083f16ae83e82c9c61ccfabbbca3 to your computer and use it in GitHub Desktop.
Bash function to checkout and update dependencies in a Rails project
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
cob() { | |
git checkout $1 | |
git fetch origin | |
update_js="$(git diff --name-only origin/$1 package.json)" | |
update_sql="$(git diff --name-only origin/$1 db/structure.sql)" | |
update_gem="$(git diff --name-only origin/$1 Gemfile)" | |
git pull | |
if [ -n "${update_js}" ]; then | |
yarn install --check-files | |
fi | |
if [ -n "${update_sql}" ]; then | |
rails db:reset | |
fi | |
if [ -n "${update_gem}" ]; then | |
bundle | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of utilisation:
cob main