Support for git tags in dependencies

Benjamin Nortier bjnortier at gmail.com
Wed Sep 15 06:45:15 EDT 2010


Hi

When using a tag instead of a branch in a git dependency (within
rebar.config), you receive this note:

Note: moving to 'webmachine-1.7.1' which isn't a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
  git checkout -b <new_branch_name>

and end up with a (no-branch) branch in your deps. So I've added some
functionality which allows you to define a git dependency like this:

{webmachine, "1.*", {git, "http://github.com/bjnortier/webmachine.git",
"master"}}
or
{webmachine, "1.*", {git, "http://github.com/bjnortier/webmachine.git",
{branch, "master"}}}
or
{webmachine, "1.*", {git, "http://github.com/bjnortier/webmachine.git",
{tag, "webmachine-1.7.1"}}}

where {tag, Tag} will use "git checkout -b"

Patch below (& attached).

Cheers
Ben

--

# HG changeset patch
# User bjnortier at gmail.com
# Date 1284545453 -3600
# Node ID 4e90aa5078290c214b2a1563a5c2e1b770bab1f0
# Parent  3fa6964f0ac0a44c152fd89471e6daa118cb0574
Added support for checking out tags from git

diff -r 3fa6964f0ac0 -r 4e90aa507829 src/rebar_deps.erl
--- a/src/rebar_deps.erl Tue Aug 31 12:41:34 2010 +0200
+++ b/src/rebar_deps.erl Wed Sep 15 11:10:53 2010 +0100
@@ -269,10 +269,16 @@
     ok = filelib:ensure_dir(AppDir),
     rebar_utils:sh(?FMT("hg clone -U ~s ~s", [Url,
filename:basename(AppDir)]), [], filename:dirname(AppDir)),
     rebar_utils:sh(?FMT("hg update ~s", [Rev]), [], AppDir);
-download_source(AppDir, {git, Url, Rev}) ->
+download_source(AppDir, {git, Url, {branch, Branch}}) ->
     ok = filelib:ensure_dir(AppDir),
     rebar_utils:sh(?FMT("git clone -n ~s ~s", [Url,
filename:basename(AppDir)]), [], filename:dirname(AppDir)),
-    rebar_utils:sh(?FMT("git checkout ~s", [Rev]), [], AppDir);
+    rebar_utils:sh(?FMT("git checkout ~s", [Branch]), [], AppDir);
+download_source(AppDir, {git, Url, {tag, Tag}}) ->
+    ok = filelib:ensure_dir(AppDir),
+    rebar_utils:sh(?FMT("git clone -n ~s ~s", [Url,
filename:basename(AppDir)]), [], filename:dirname(AppDir)),
+    rebar_utils:sh(?FMT("git checkout -b ~s", [Tag]), [], AppDir);
+download_source(AppDir, {git, Url, Rev}) ->
+    download_source(AppDir, {git, Url, {branch, Rev}});
 download_source(AppDir, {bzr, Url, Rev}) ->
     ok = filelib:ensure_dir(AppDir),
     rebar_utils:sh(?FMT("bzr branch -r ~s ~s ~s",
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/rebar_lists.basho.com/attachments/20100915/5d711627/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tag_support.patch
Type: application/octet-stream
Size: 1515 bytes
Desc: not available
URL: <http://lists.basho.com/pipermail/rebar_lists.basho.com/attachments/20100915/5d711627/attachment.patch>


More information about the rebar mailing list