Skip to content

Instantly share code, notes, and snippets.

@sandrocarval
Last active December 19, 2016 19:56
Show Gist options
  • Save sandrocarval/b493a48d4be15b5602ab1fe1830954d1 to your computer and use it in GitHub Desktop.
Save sandrocarval/b493a48d4be15b5602ab1fe1830954d1 to your computer and use it in GitHub Desktop.
Script para facilitar a mudança de tags/commits nos diretórios das gems quando se dá checkout no branch do projeto principal (Jericó, JIS, JPS)
#!/bin/bash
# Salve este arquivo no $HOME/bin e adicione o caminho no $PATH
REPO_BASE="$HOME/repos"
CURRENT_REPO=$(pwd)
git checkout $1
for REPO in $(egrep "adtsys-cloud|diegoaltheman" $CURRENT_REPO/Gemfile | awk -F'"' '{print $2}')
do
CHECKOUT_VALUE=$(grep "$REPO" $CURRENT_REPO/Gemfile | awk -F'"' '{print $6}')
echo "$REPO: checking out $CHECKOUT_VALUE"
cd $REPO_BASE/$REPO && git checkout $CHECKOUT_VALUE >/dev/null 2>&1
done
@sandrocarval
Copy link
Author

Exemplo de saída:

$ gco homolog
Previous HEAD position was 666666... Commit louco
Switched to branch 'homolog'
Your branch is up-to-date with 'origin/homolog'.
gem-interna-1: checking out v0.3.0
gem-interna-2: checking out v0.3.2
gem-interna-3: checking out v0.0.6
gem-interna-4: checking out v0.0.9.1
gem-interna-5: checking out v0.0.1

@sandrocarval
Copy link
Author

Funciona se a linha no Gemfile estiver em um desses formatos:

gem "gem-interna-123", git: "xpto/gem-interna-123.git", tag: "v0.0.6.9"
gem "gem-interna-234", git: "xpto/gem-interna-234.git", ref: "6669e6d594d34f6e1a2b28352331719685864666"
gem "gem-interna-345", git: "xpto/gem-interna-345.git", branch: "homolog"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment