Make sure we find git at app start time
[catagits/Gitalist.git] / lib / Gitalist / Utils.pm
index 0df4973..f11dc34 100644 (file)
@@ -45,6 +45,11 @@ sub age_string {
   return $age_str;
 }
 
+sub is_binary {
+  # Crappy heuristic - does the first line or so look printable?
+  return $_[0] !~ /^[[:print:]]+$ (?: \s ^[[:print:]]+$ )?/mx;
+}
+
 1;
 
 __END__
@@ -57,7 +62,11 @@ Gitalist::Utils - trivial utils for Gitalist
 
 =head2 age_string
 
-Turns an integer number of seconds into a string..
+Turns an integer number of seconds into a string.
+
+=head2 is_binary
+
+Check whether a string is binary according to C<-B>.
 
 =head1 AUTHORS