Last active
December 26, 2015 23:19
-
-
Save raphink/7229838 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export GH_USER="raphink" | |
## Github helpers | |
function gh_exists_remote { | |
local repo="$1" | |
git remote | grep -q "^${repo}$" \ | |
&& return 0 || return 1 | |
} | |
function gh_add_repo { | |
local repo="$1" | |
gh_exists_remote gh-c2c-$repo || \ | |
git remote add gh-c2c-$repo [email protected]:camptocamp/puppet-$repo.git 2>/dev/null | |
if [ -z $GH_USER ]; then | |
echo "Warning: set \$GH_USER to add the user repository automatically" >&2 | |
else | |
gh_exists_remote gh-$GH_USER-$repo || \ | |
git remote add gh-$GH_USER-$repo [email protected]:$GH_USER/puppet-$repo.git 2>/dev/null | |
fi | |
} | |
function gs_pull_c2c { | |
local repo="$1" | |
gh_add_repo "$repo" | |
git subtree pull --prefix=modules/$repo gh-c2c-$repo | |
} | |
function _gs_complete { | |
local cur | |
cur=$(_get_cword "=") | |
COMPREPLY=( $(compgen -W "$(ls modules)" -- "${cur}") ) | |
} | |
complete -F _gs_complete gs_pull_c2c | |
complete -F _gs_complete gh_add_repo | |
complete -F _gs_complete gh_exists_remote |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment