Skip to content

Instantly share code, notes, and snippets.

@jonboulle
Created February 4, 2015 23:23
Show Gist options
  • Save jonboulle/1d99f1856cbe941ce1df to your computer and use it in GitHub Desktop.
Save jonboulle/1d99f1856cbe941ce1df to your computer and use it in GitHub Desktop.
#!/bin/bash -eu
tmpdir=$(mktemp -d)
repodir=$(pwd)
# first try to extract parts from the remote
# e.g. github.com/foo/bar/baz
# -> remote = github.com
remote=$(git ls-remote --get-url origin|awk -F ':' '{print $1}'|awk -F '@' ' {print $2}')
# -> path = foo/bar/baz
path=$(git ls-remote --get-url origin|awk -F ':' '{print $2}'|awk -F '.' '{p rint $1}')
if [ -z ${path} ]; then
echo "couldn't get path"
exit 255
fi
# github.com/foo/bar
package=${remote}/${path}
# baz
name=$(basename ${path})
# Godep does not work with symbolic links, soooo... get the package afresh
export GOPATH=${tmpdir}
cd ${tmpdir}
go get -d ${package}/...
cd src/${package}
godep restore
# Now everything is set up, time to update/add new deps
echo pushd ${tmpdir}/src/${package}
PS1=": godep ; "
# godep update ...
# godep save -r ./...
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment