Initial support for git submodules.
This commit is contained in:
parent
5bbac7755a
commit
4d6653ecc3
1 changed files with 32 additions and 0 deletions
32
bin/get
32
bin/get
|
|
@ -9,6 +9,10 @@ list_remote_branches() {
|
||||||
git for-each-ref refs/heads --format="%(refname:short)"
|
git for-each-ref refs/heads --format="%(refname:short)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
git_root() {
|
||||||
|
git rev-parse --show-toplevel
|
||||||
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
'?' | status)
|
'?' | status)
|
||||||
# TODO: Display help if not inside a repo
|
# TODO: Display help if not inside a repo
|
||||||
|
|
@ -300,6 +304,34 @@ git log --color \
|
||||||
--abbrev-commit -10 "${@:2}"
|
--abbrev-commit -10 "${@:2}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
submodule)
|
||||||
|
CWD=$(pwd)
|
||||||
|
gitroot=$(git_root)
|
||||||
|
shopt -s globstar
|
||||||
|
# For every git repository found within...
|
||||||
|
for dir in $gitroot/*/**/.git
|
||||||
|
do
|
||||||
|
cd "$dir"
|
||||||
|
# Get relative directory name
|
||||||
|
reldir=${dir#$gitroot/}
|
||||||
|
reldir=${reldir%/.git}
|
||||||
|
echo "[submodule \"$reldir\"]"
|
||||||
|
# Get local branch name
|
||||||
|
local_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
# Get associated remote
|
||||||
|
remote=$(git config --get branch.$local_branch.remote)
|
||||||
|
# Get url of remote
|
||||||
|
url=$(git config --get remote.$remote.url)
|
||||||
|
echo "url = $url"
|
||||||
|
cd "$gitroot"
|
||||||
|
git submodule add "$url" "$reldir"
|
||||||
|
echo ''
|
||||||
|
done
|
||||||
|
cd "$gitroot"
|
||||||
|
git submodule init
|
||||||
|
cd "$CWD"
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
echo "Passing args straight to git..."
|
echo "Passing args straight to git..."
|
||||||
git $@
|
git $@
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue