Skip to content

Instantly share code, notes, and snippets.

@debedb
Last active February 10, 2017 20:01

Revisions

  1. debedb revised this gist Feb 10, 2017. 1 changed file with 35 additions and 10 deletions.
    45 changes: 35 additions & 10 deletions Go vendoring
    Original file line number Diff line number Diff line change
    @@ -1,23 +1,48 @@
    #!/bin/sh
    set -x
    if [ "$1" == "" ]; then
    echo "Usage: $0 <PROJECT_ROOT> <GITHUB_REPO>"
    echo "Usage: $0 <REPO_PATH> [<PROJECT_ROOT>] [<branch>]"
    exit 1
    fi
    if [ "$2" == "" ]; then
    echo "Usage: $0 <PROJECT_ROOT> <GITHUB_REPO>"
    exit 1


    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

    $branch=$3
    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 $1
    git submodule add https://github.com/${2}.git vendor/github.com/$2
    cd vendor/github.com/$2
    cd $project_root
    git submodule add --force https://$host/${path}.git vendor/$host/$path
    cd vendor/$host/$path
    git checkout $branch
    cd -
    git add $2
    git commit -m "Added github.com/$2"
    git add vendor/$host/$path
    git commit -m "Added $host/$repo"
    git submodule update --init -f


  2. debedb revised this gist Oct 2, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Go vendoring
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ fi
    cd $1
    git submodule add https://github.com/${2}.git vendor/github.com/$2
    cd vendor/github.com/$2
    git checkout master
    git checkout $branch
    cd -
    git add $2
    git commit -m "Added github.com/$2"
  3. debedb revised this gist Mar 14, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Go vendoring
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ if [ "$branch" == "" ]; then
    fi

    cd $1
    git submodule add git@github.com:${2}.git vendor/github.com/$2
    git submodule add https://github.com/${2}.git vendor/github.com/$2
    cd vendor/github.com/$2
    git checkout master
    cd -
  4. debedb created this gist Oct 19, 2015.
    23 changes: 23 additions & 0 deletions Go vendoring
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #!/bin/sh
    if [ "$1" == "" ]; then
    echo "Usage: $0 <PROJECT_ROOT> <GITHUB_REPO>"
    exit 1
    fi
    if [ "$2" == "" ]; then
    echo "Usage: $0 <PROJECT_ROOT> <GITHUB_REPO>"
    exit 1
    fi

    $branch=$3
    if [ "$branch" == "" ]; then
    branch=master
    fi

    cd $1
    git submodule add [email protected]:${2}.git vendor/github.com/$2
    cd vendor/github.com/$2
    git checkout master
    cd -
    git add $2
    git commit -m "Added github.com/$2"