Last active
August 29, 2015 14:14
-
-
Save perlpilot/d3001269e80f26915a27 to your computer and use it in GitHub Desktop.
This file contains 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
diff --git a/lib/Panda/Fetcher.pm b/lib/Panda/Fetcher.pm | |
index 256f9d8..f263bc7 100644 | |
--- a/lib/Panda/Fetcher.pm | |
+++ b/lib/Panda/Fetcher.pm | |
@@ -4,16 +4,18 @@ use Shell::Command; | |
method fetch($from, $to) { | |
given $from { | |
+ my $commit; | |
+ $from.=subst(/ '@' (<[ . / ]+alpha+digit>+) $/, { $commit = $0; "" }); | |
when /\.git$/ { | |
- return git-fetch $from, $to; | |
+ return git-fetch $from, $to, $commit; | |
} | |
when /^ $<schema>=[<alnum><[+.-]+alnum>*] '://' / { | |
when $<schema> { | |
when /^'git://'/ { | |
- return git-fetch $from, $to; | |
+ return git-fetch $from, $to, $commit; | |
} | |
when /^[http|https]'+git://'/ { | |
- return git-fetch $from.subst(/'+git'/, ''), $to; | |
+ return git-fetch $from.subst(/'+git'/, ''), $to, $commit; | |
} | |
when /^'file://'/ { | |
return local-fetch $from.subst(/^'file://'/, ''), $to; | |
@@ -34,9 +36,13 @@ method fetch($from, $to) { | |
return True; | |
} | |
-sub git-fetch($from, $to) { | |
+sub git-fetch($from, $to, $commit = Nil) { | |
shell "git clone -q $from \"$to\"" | |
or fail "Failed cloning git repository '$from'"; | |
+ if $commit { | |
+ temp $*CWD = chdir($to); | |
+ shell "git checkout $commit"; | |
+ } | |
return True; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment