Last active
February 10, 2017 20:01
-
-
Save debedb/cc4971e03f5321c289ad 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
#!/bin/sh | |
set -x | |
if [ "$1" == "" ]; then | |
echo "Usage: $0 <REPO_PATH> [<PROJECT_ROOT>] [<branch>]" | |
exit 1 | |
fi | |
repo=$1 | |
# Check if repo is relative | |
path=$(echo $repo | cut -d/ -f3) | |
if [ "$path" == "" ]; then | |
host="github.com" | |
path=$repo | |
else | |
host=$(echo $repo | cut -d/ -f1) | |
path=$(echo $repo | cut -d/ -f2,3) | |
fi | |
project_root=$2 | |
if [ "$project_root" == "" ]; then | |
project_root=`pwd` | |
echo "Set project root to cwd: ${project_root}" | |
fi | |
git_dir="$project_root/.git" | |
if ! [ -d $git_dir ]; then | |
echo "$project_root is not a Git repo: $git_dir not found." | |
exit 1 | |
fi | |
branch=$3 | |
if [ "$branch" == "" ]; then | |
branch=master | |
fi | |
cd $project_root | |
git submodule add --force https://$host/${path}.git vendor/$host/$path | |
cd vendor/$host/$path | |
git checkout $branch | |
cd - | |
git add vendor/$host/$path | |
git commit -m "Added $host/$repo" | |
git submodule update --init -f | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment