about summary refs log tree commit homepage
path: root/t/common.perl
diff options
context:
space:
mode:
Diffstat (limited to 't/common.perl')
-rw-r--r--t/common.perl14
1 files changed, 14 insertions, 0 deletions
diff --git a/t/common.perl b/t/common.perl
index 688e30ad..e49a5965 100644
--- a/t/common.perl
+++ b/t/common.perl
@@ -39,4 +39,18 @@ sub spawn_listener {
         $pid;
 }
 
+sub require_git ($;$) {
+        my ($req, $maybe) = @_;
+        my ($req_maj, $req_min) = split(/\./, $req);
+        my ($cur_maj, $cur_min) = (`git --version` =~ /version (\d+)\.(\d+)/);
+
+        my $req_int = ($req_maj << 24) | ($req_min << 16);
+        my $cur_int = ($cur_maj << 24) | ($cur_min << 16);
+        if ($cur_int < $req_int) {
+                return 0 if $maybe;
+                plan skip_all => "git $req+ required, have $git_ver";
+        }
+        1;
+}
+
 1;