@@ -124,11 +124,47 @@ function bake_url_to_package_path () {
124124 echo " $BAKE_PACKAGES_PATH /$fpath "
125125}
126126
127+ function bake_require_git () {
128+ local url=" $1 "
129+ local libpath=" $2 "
130+ local tag=" ${3:- master} "
131+
132+ bake_ensure_bake_packages_path
133+
134+ pushd $BAKE_PACKAGES_PATH > /dev/null
135+
136+ # git@github.com:kyleburton/bake-recipes.git
137+ # https://github.com/kyleburton/bake-recipes.git
138+ # strip the leading git@, http:// or https://
139+ local full_package_path=" $( echo " $url " | sed ' s/^git@//' | sed ' s/https:\/\///' | sed ' s/http:\/\///' | sed ' s/.git$//' | sed ' s/:/\//' ) "
140+ local package_path=" $( dirname " $full_package_path " ) "
141+
142+ test -d " $package_path " || mkdir -p " $package_path "
143+ cd " $package_path "
144+ local dname=" $( basename " $full_package_path " ) "
145+ if [ ! -d " $dname " ]; then
146+ git clone " $url "
147+ cd " $dname "
148+ git fetch
149+ git co " $tag "
150+ fi
151+
152+ popd
153+
154+ # translate the require path to local fs path
155+ # source it!
156+ source " $BAKE_PACKAGES_PATH /$full_package_path /$libpath "
157+ }
158+
159+ function bake_ensure_bake_packages_path () {
160+ test -d $BAKE_PACKAGES_PATH || mkdir -p $BAKE_PACKAGES_PATH
161+ }
162+
127163function bake_package_install () {
128164 local url=" $1 "
129165 local tag=" ${2:- master} "
130166
131- test -d $BAKE_PACKAGES_PATH || mkdir -p $BAKE_PACKAGES_PATH
167+ bake_ensure_bake_packages_path
132168 pushd $BAKE_PACKAGES_PATH
133169 local git_project_name=" $( echo $url | awk -F/ ' {print $3 }' ) "
134170 local git_host_and_user=" $( echo $url | awk -F/ ' {print $1 "/" $2 }' ) "
0 commit comments