Skip to content

Instantly share code, notes, and snippets.

@perlpilot
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perlpilot/d3001269e80f26915a27 to your computer and use it in GitHub Desktop.
Save perlpilot/d3001269e80f26915a27 to your computer and use it in GitHub Desktop.
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