A series of reverts involving win32 related hacks.
Dan Brook [Mon, 29 Mar 2010 16:41:56 +0000 (17:41 +0100)]
Revert "Further win32 related hacks."

This reverts commit 140c970f902ac49e196a2638c016bcf60c704a23.

Revert "Abstracted kludges a little more."

This reverts commit 4b59c2c514cda8914018f12051345e04132ae5b0.

Revert "Two kludges to get Gitalist *running* on Strawberry Perl."

This reverts commit aa0983cf960c132869ba3e8fe336033e3e1132e8.

Revert "Revert "Abstracted kludges a little more.""

This reverts commit 8430d5c62c647b87399acfe17c71768569484b04.

Conflicts:

    lib/Gitalist/Git/Object.pm
    lib/Gitalist/Git/Repository.pm

Revert "Revert "Revert "Abstracted kludges a little more."""

This reverts commit 16d3d68195fa1d0f20f1a494a8d76de1e2d5cf51.

lib/Gitalist/Git/Object.pm
lib/Gitalist/Git/Repository.pm
t/02git_CollectionOfRepositories_FromDirectory.t
t/02git_Repository.t
t/02git_util.t

index 2daf3ec..4448790 100644 (file)
@@ -5,18 +5,6 @@ class Gitalist::Git::Object {
     use MooseX::Types::Moose qw/Str Int Bool Maybe ArrayRef/;
     use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
 
-    use Fcntl ':mode';
-    use constant {
-        S_IFINVALID => 0030000,
-        S_IFGITLINK => 0160000,
-    };
-
-    BEGIN {
-        no warnings;
-        *S_ISLNK = sub ($) {}
-            if $^O eq 'MSWin32';
-    }
-
     # repository and sha1 are required initargs
     has repository => ( isa => 'Gitalist::Git::Repository',
                      required => 1,
@@ -80,11 +68,16 @@ class Gitalist::Git::Object {
     }
 
     method _build_modestr {
-       # XXX The POSIX constants make win32 sad :(
         return _mode_str($self->mode);
     }
 
-    # via gitweb.pm
+    # via gitweb.pm circa line 1305
+    use Fcntl ':mode';
+    use constant {
+        S_IFINVALID => 0030000,
+        S_IFGITLINK => 0160000,
+    };
+
     # submodule/subrepository, a commit object reference
     sub S_ISGITLINK($) {
         return (($_[0] & S_IFMT) == S_IFGITLINK)
index 03239c8..7e873cd 100644 (file)
@@ -11,16 +11,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
     use List::MoreUtils qw/any zip/;
     use DateTime;
     use Encode qw/decode/;
-
-    use if $^O ne 'MSWin32', 'I18N::Langinfo', => qw/langinfo CODESET/;
-    BEGIN {
-        no strict 'subs';
-        *__owner = defined &langinfo
-            ? sub { map { decode(langinfo(CODESET), $_) } (getpwuid $_[0]->path->stat->uid)[6,0] }
-            : sub { return qw/OwnEr GroUp/ }
-        ;
-    }
-
+    use I18N::Langinfo qw/langinfo CODESET/;
     use Gitalist::Git::Object::Blob;
     use Gitalist::Git::Object::Tree;
     use Gitalist::Git::Object::Commit;
@@ -147,7 +138,6 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
         if ($search) {
             $search->{type} = 'grep'
                 if $search->{type} eq 'commit';
-           no warnings; # where's this warning coming from?
             @search_opts = (
                 # This seems a little fragile ...
                 qq[--$search->{type}=$search->{text}],
@@ -263,7 +253,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
     }
 
     method _build_owner {
-        my ($gecos, $name) = $self->__owner;
+        my ($gecos, $name) = map { decode(langinfo(CODESET), $_) } (getpwuid $self->path->stat->uid)[6,0];
         $gecos =~ s/,+$//;
         return length($gecos) ? $gecos : $name;
     }
index ac590ef..41f7699 100644 (file)
@@ -12,7 +12,7 @@ my $repo_dir = "$Bin/lib/repositories";
 my $repo = Gitalist::Git::CollectionOfRepositories::FromDirectory->new( repo_dir => $repo_dir );
 isa_ok($repo, 'Gitalist::Git::CollectionOfRepositories::FromDirectory');
 
-is($repo->repo_dir, Path::Class::Dir->new($repo_dir), "repo->repo_dir is correct" );
+is($repo->repo_dir, $repo_dir, "repo->repo_dir is correct" );
 
 # 'bare.git' is a bare git repository in the repository dir
 use Path::Class;
index 176651d..e8ee762 100644 (file)
@@ -8,19 +8,16 @@ use Encode qw/decode_utf8/;
 use Data::Dumper;
 
 BEGIN {
-    # Don't die on win32.
-    eval {
-      # Mocking to allow testing regardless of the user's locale
-      require I18N::Langinfo;
-      no warnings 'redefine';
-      *I18N::Langinfo::langinfo = sub($) {
+    # Mocking to allow testing regardless of the user's locale
+    require I18N::Langinfo;
+    no warnings 'redefine';
+    *I18N::Langinfo::langinfo = sub($) {
         return "UTF-8" if $_[0] == I18N::Langinfo::CODESET();
-      };
-      *CORE::GLOBAL::getpwuid = sub {
+    };
+    *CORE::GLOBAL::getpwuid = sub {
         wantarray
-         ? ("test", "x", "1000", "1000", "", "", "T\x{c3}\x{a9}st", "/home/test", "/bin/bash")
-          : "test";
-      };
+            ? ("test", "x", "1000", "1000", "", "", "T\x{c3}\x{a9}st", "/home/test", "/bin/bash")
+            : "test";
     };
 }
 
@@ -78,10 +75,7 @@ like($proj->head_hash('HEAD'), qr/^([0-9a-fA-F]{40})$/, 'head_hash');
     isa_ok($tree[0], 'Gitalist::Git::Object', 'tree element 0');
 }
 
-# Be win32 friendly. Poor poor win32.
-if($^O ne 'MSWin32') {
-  my $owner = $proj->owner;
-  is_flagged_utf8($owner, "Owner name is flagged as utf8");
-  is_sane_utf8($owner, "Owner name is not double-encoded");
-  is($owner, decode_utf8("T\x{c3}\x{a9}st"),  "Owner name is correct");
-}
+my $owner = $proj->owner;
+is_flagged_utf8($owner, "Owner name is flagged as utf8");
+is_sane_utf8($owner, "Owner name is not double-encoded");
+is($owner, decode_utf8("T\x{c3}\x{a9}st"),  "Owner name is correct");
index 7cb99c5..94f82f7 100644 (file)
@@ -19,7 +19,7 @@ my $util = Gitalist::Git::Util->new(
 );
 isa_ok($util, 'Gitalist::Git::Util');
 
-like( $util->_git, qr#\bgit(?:.CMD)$#, 'git binary found');
+like( $util->_git, qr#/git$#, 'git binary found');
 isa_ok($util->gpp, 'Git::PurePerl', 'gpp instance created');
 
 done_testing;