Git-PurePerl-0.53/000755 000767 000024 00000000000 12770006122 014342 5ustar00dbrookstaff000000 000000 Git-PurePerl-0.53/CHANGES000644 000767 000024 00000013103 12770000223 015327 0ustar00dbrookstaff000000 000000 Revision history for Perl module Git::PurePerl: 0.53 Mon 19 Sep 2016 16:12:45 BST - Add support for creating merge commits to Git::PurePerl::Object::Commit (Philippe Bruhat (BooK)) 0.52 Sat Jun 11 22:22:04 CEST 2016 - fix 'Can't redeclare "my" in "my" ...' error in 5.24 (gregor herrmann) 0.51 Fri Mar 6 13:58:39 CET 2015 - Fix failing test if there is no internet access (Bugdebugger) - Update repository link in PurePerl.pm (Bugdebugger) - Update repository link (Сергей Романов) 0.50 Sat Jan 25 14:58:16 CET 2014 - Now with the changes from 0.49 in CHANGES. That's it. 0.49 Sat Jan 25 14:55:42 CET 2014 - qw() in list context is an error now (gregor herrmann) - Fixed RT#90667 (Zoffix Znet) 0.48 Thu Jul 14 22:53:55 BST 2011 - Translation from Digest::SHA1 to Digest::SHA (Jonas Genannt) - A git object can also be of zero size. (Christian Walde) - Only the last SHA1 for any given ref is returned from ref_sha1() (Christian Walde) - Make sure zlib data is always read as-is (Christian Walde) 0.47 Wed Aug 11 13:29:06 BST 2010 - Lazily build the fh attribute of Git::PurePerl::Pack objects. 0.46_01 Sat 16 Jan 13:42:00 GMT 2010 - Add support for ssh:// and file:// protocols (Alex Vandiver) 0.46 Tue 12 Jan 01:09:00 GMT 2010 - Add config file handling via Config::GitLike - Fix a couple of memory leaks due to unweakened circular references. - Handle commit object character encoding correctly 0.45 Mon 21st Dec 12:36:29 GMT 2009 - Be Win32 compatible (RT#52677), patch contributed by kmx. 0.44 Sat 19th Dec 15:31:00 GMT - Fix ref_sha1 to return rather than calling next as not in a loop. (doy) - Add support for the special HEAD ref, and associated head and head_sha1 methods - Grok symbolic references - Default to the current directory in the checkout method 0.43 Wed 25 Nov 2009 19:46:38 GMT 2009 - Switch to Module::Install so we can have repository metadata in META.yml - No other changes from the previous 0.42_01 dev release. 0.42_01 Mon Nov 23 12:12:51 GMT 2009 - allow put_object to update other heads than just 'master' (thanks to martijn) - Fix bug when the ref dirs are more than two levels deep - Fix commit object to support multiple parents. This is seen in merge commits - Add object_kind method to tag objects. - Change to MANIFEST.SKIP based dist building. - Dev release with version bump skipping 0.42 so that Gitalist can depend on >= 0.42 but we don't have to push a real release until I've done a little more maintainance work. 0.41 Tue Apr 21 20:41:07 BST 2009 - allow subdirectories in .git/refs/*/ (thanks to martijn) - run protocol.t test with --base-path to not care about where on the filesystem the checkout is (thanks to martijn) - when parsing a commit, split up the author and committer fields into name, email and commit time. This adds two new DateTime fields, authored_time and committed_time to ::Commit and changes the type of the author and committer fields to Git::PurePerl::Actor, which is an object with name and email fields (thanks to martijn) - add the parent field to a new commit when available (thanks to martijn) - allow bare repositories with the gitdir parameter (thanks to martijn) - fill new commits with real author, authored_time, committer, committed_time and comment (thanks to martijn) 0.40 Fri Mar 13 15:29:02 GMT 2009 - Skip protocol tests on Win32 (thanks to fayland) - Add description (thanks to fayland) 0.39 Fri Mar 13 10:14:57 GMT 2009 - add a method to generate the sha1 of an object - add a raw method to objects - add new set of classes to add objects - add class to talk the git protocol - add a method to checkout the head - add a method to return the references - add a method to return the commit for a reference - fix bug where it would not find an object if there was a mixture of packs and loose objects - fix bug to do with empty files - split methods into those that returns sha1s and those that return objects - add class to index packs - make it work under Win32 (thanks to fayland) 0.38 Thu Dec 18 10:26:49 GMT 2008 - add init() method to create a new repository - create Git::PurePerl::Loose to handle loose objects - make Git::PurePerl::Pack's all_sha1s return a stream 0.37 Fri Dec 12 16:18:02 GMT 2008 - add minimal docs (thanks to tokuhirom) - speed everything up by making the classes immutable - lazily build packs - simplify the code by splitting pack index reading into Git::PurePerl::PackIndex::Version1 and Git::PurePerl::PackIndex::Version2 - minor tidying of code 0.36 Wed Nov 26 21:49:33 GMT 2008 - add a class to represent tags - complain if the directory does not have a .git directory - remove commented-out code - only open a pack file or index once - remove some unnecessary seeks 0.35 Tue Nov 25 17:37:56 GMT 2008 - add Data::Stream::Bulk as a prerequisite - add all_sha1s method 0.34 Fri Nov 21 17:20:17 GMT 2008 - speed up finding objects in pack files by using a binary search algorithm 0.33 Thu Nov 20 09:28:36 GMT 2008 - add support for version 2 pack index files - add support for ref_delta objects in pack files - add support for ofs_delta objects in pack files - update with cleaner tars 0.32 Fri Nov 14 16:47:59 GMT 2008 - initial release Git-PurePerl-0.53/inc/000755 000767 000024 00000000000 12770006121 015112 5ustar00dbrookstaff000000 000000 Git-PurePerl-0.53/lib/000755 000767 000024 00000000000 12770006121 015107 5ustar00dbrookstaff000000 000000 Git-PurePerl-0.53/Makefile.PL000644 000767 000024 00000002022 12767765163 016337 0ustar00dbrookstaff000000 000000 #!perl use strict; use warnings; use inc::Module::Install 0.91; name 'Git-PurePerl'; all_from 'lib/Git/PurePerl.pm'; author 'Leon Brocard '; abstract 'A Pure Perl interface to Git repositories'; license 'perl'; resources repository => 'git://github.com/broquaint/git-pureperl.git'; requires 'Archive::Extract' => '0'; requires 'Compress::Raw::Zlib' => '0'; requires 'Compress::Zlib' => '0'; requires 'Config::GitLike' => '0'; requires 'Data::Stream::Bulk' => '0'; requires 'DateTime' => '0'; requires 'File::Find::Rule' => '0'; requires 'IO::Digest' => '0'; requires 'Moose' => '0'; requires 'MooseX::StrictConstructor' => '0'; requires 'MooseX::Types::Path::Class' => '0'; requires 'namespace::autoclean'; test_requires 'Test::More' => '0.88'; test_requires 'Test::utf8' => '0.02'; WriteAll; Git-PurePerl-0.53/MANIFEST000644 000767 000024 00000002455 12770000244 015500 0ustar00dbrookstaff000000 000000 CHANGES inc/Module/Install.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm inc/Module/Install/Fetch.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm lib/Git/PurePerl.pm lib/Git/PurePerl/Actor.pm lib/Git/PurePerl/Config.pm lib/Git/PurePerl/DirectoryEntry.pm lib/Git/PurePerl/Loose.pm lib/Git/PurePerl/NewDirectoryEntry.pm lib/Git/PurePerl/NewObject.pm lib/Git/PurePerl/NewObject/Blob.pm lib/Git/PurePerl/NewObject/Commit.pm lib/Git/PurePerl/NewObject/Tag.pm lib/Git/PurePerl/NewObject/Tree.pm lib/Git/PurePerl/Object.pm lib/Git/PurePerl/Object/Blob.pm lib/Git/PurePerl/Object/Commit.pm lib/Git/PurePerl/Object/Tag.pm lib/Git/PurePerl/Object/Tree.pm lib/Git/PurePerl/Pack.pm lib/Git/PurePerl/Pack/WithIndex.pm lib/Git/PurePerl/Pack/WithoutIndex.pm lib/Git/PurePerl/PackIndex.pm lib/Git/PurePerl/PackIndex/Version1.pm lib/Git/PurePerl/PackIndex/Version2.pm lib/Git/PurePerl/Protocol.pm lib/Git/PurePerl/Protocol/File.pm lib/Git/PurePerl/Protocol/Git.pm lib/Git/PurePerl/Protocol/SSH.pm Makefile.PL MANIFEST This list of files META.yml MYMETA.json MYMETA.yml README t/00_setup.t t/checkout/file.txt t/encoding.t t/init.t t/protocol.t t/protocol_gpp.t t/simple.t test-encoding.tgz test-project-packs.tgz test-project-packs2.tgz test-project.tgz Git-PurePerl-0.53/META.yml000644 000767 000024 00000001636 12770000242 015616 0ustar00dbrookstaff000000 000000 --- abstract: 'A Pure Perl interface to Git repositories' author: - 'Leon Brocard ' - 'Leon Brocard ' build_requires: ExtUtils::MakeMaker: 6.36 Test::More: '0.88' Test::utf8: '0.02' configure_requires: ExtUtils::MakeMaker: 6.36 distribution_type: module dynamic_config: 1 generated_by: 'Module::Install version 1.16' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Git-PurePerl no_index: directory: - inc - t requires: Archive::Extract: 0 Compress::Raw::Zlib: 0 Compress::Zlib: 0 Config::GitLike: 0 Data::Stream::Bulk: 0 DateTime: 0 File::Find::Rule: 0 IO::Digest: 0 Moose: 0 MooseX::StrictConstructor: 0 MooseX::Types::Path::Class: 0 namespace::autoclean: 0 resources: license: http://dev.perl.org/licenses/ repository: git://github.com/broquaint/git-pureperl.git version: '0.53' Git-PurePerl-0.53/MYMETA.json000644 000767 000024 00000003235 12770000247 016236 0ustar00dbrookstaff000000 000000 { "abstract" : "A Pure Perl interface to Git repositories", "author" : [ "Leon Brocard ", "Leon Brocard " ], "dynamic_config" : 0, "generated_by" : "Module::Install version 1.16, CPAN::Meta::Converter version 2.150005", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Git-PurePerl", "no_index" : { "directory" : [ "inc", "t" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "6.36", "Test::More" : "0.88", "Test::utf8" : "0.02" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Archive::Extract" : "0", "Compress::Raw::Zlib" : "0", "Compress::Zlib" : "0", "Config::GitLike" : "0", "Data::Stream::Bulk" : "0", "DateTime" : "0", "File::Find::Rule" : "0", "IO::Digest" : "0", "Moose" : "0", "MooseX::StrictConstructor" : "0", "MooseX::Types::Path::Class" : "0", "namespace::autoclean" : "0" } } }, "release_status" : "stable", "resources" : { "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "type" : "git", "url" : "git://github.com/broquaint/git-pureperl.git" } }, "version" : "0.53", "x_serialization_backend" : "JSON::PP version 2.27300" } Git-PurePerl-0.53/MYMETA.yml000644 000767 000024 00000001624 12770000242 016061 0ustar00dbrookstaff000000 000000 --- abstract: 'A Pure Perl interface to Git repositories' author: - 'Leon Brocard , Leon Brocard ' build_requires: ExtUtils::MakeMaker: '6.36' Test::More: '0.88' Test::utf8: '0.02' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'ExtUtils::MakeMaker version 7.1001, CPAN::Meta::Converter version 2.150005' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Git-PurePerl no_index: directory: - t - inc requires: Archive::Extract: '0' Compress::Raw::Zlib: '0' Compress::Zlib: '0' Config::GitLike: '0' Data::Stream::Bulk: '0' DateTime: '0' File::Find::Rule: '0' IO::Digest: '0' Moose: '0' MooseX::StrictConstructor: '0' MooseX::Types::Path::Class: '0' namespace::autoclean: '0' version: '0.53' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Git-PurePerl-0.53/README000644 000767 000024 00000001343 12767765163 015252 0ustar00dbrookstaff000000 000000 NAME Git::PurePerl - A Pure Perl interface to Git repositories SYNOPSIS my $git = Git::PurePerl->new( directory => '/path/to/git/' ); $git->master->committer; $git->master->comment; $git->get_object($git->master->tree); DESCRIPTION This module is a Pure Perl interface to Git repositories. It was mostly based on Grit . METHODS master get_object get_object_packed get_object_loose create_object all_sha1s AUTHOR Leon Brocard COPYRIGHT Copyright (C) 2008, Leon Brocard. LICENSE This module is free software; you can redistribute it or modify it under the same terms as Perl itself. Git-PurePerl-0.53/t/000755 000767 000024 00000000000 12770006122 014605 5ustar00dbrookstaff000000 000000 Git-PurePerl-0.53/test-encoding.tgz000644 000767 000024 00000016717 12767765163 017676 0ustar00dbrookstaff000000 000000 6KK] y>k0cT%wnnO'0JݙwϝO=?Em1,9#$s9)sB:,IyIeGeQܙg.XZ?R?]7VfE> Z@mЙd_̵?'HRVRg\[?¿5;vtkzbeZ8i=z_Wo8ꕵ<̈ߥ2y9nbҊSrnb/SX)X>SHݠOc)'6%Y_7(i-rAsblQ]E!H99'N5IZu6 K?JI#K'1wtܪOQ׳!3 :oxLS]bUZ  ظ% vW,3x T!>xԅ'l~^'ZA) YAkO<j?=kXn2Onam Ֆ-3O_]O>u:?+ɅRJ6ϋb^3tAZh䤂9-'.?^ j%_k{z쯮pq/(w:뿠h\țT-P )r!e|!k&c/I\E+4[7.q՝ɵUU.h͋?ggoy1pO߅^ѤߖNټDkcg܇xS;vo{?䗞?|~@^C⏾zTytS]5U\`"g6Uӿw:?YES S]Q%IsʚXuŀ쿘L=w_Iݡ5.|+&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M6lևďeѳE7;!y?ðJKjIΣ sdKµA5 l dȽѝU;{ػzVWup`dyhsص1*t`վXKld3o/>Kۉ-m߽9?vK[4C/hE+ZW/jGit-PurePerl-0.53/t/00_setup.t000644 000767 000024 00000001767 12767765163 016473 0ustar00dbrookstaff000000 000000 #!perl use strict; use warnings; use Test::More; use Archive::Extract; foreach my $name (qw(test-project test-project-packs test-project-packs2 test-encoding)) { next if -d $name; my $ae = Archive::Extract->new( archive => "$name.tgz" ); $ae->extract; } ok(1, 'extracted'); done_testing; =for shell # How to create test-project and test-project-packs: mkdir test-project cd test-project git init git config user.name "Your Name Comes Here" git config user.email you@yourdomain.example.com echo 'hello world' > file.txt git add . git commit -a -m "initial commit" echo 'hello world!' >file.txt git commit -a -m "add emphasis" echo "hello world, again" >>file.txt git commit -a -m "add again" cd .. tar fvzc test-project.tgz test-project cd test-project git gc cd .. mv test-project test-project-packs tar fvzc test-project-packs.tgz test-project-packs rm -rf test-project-packs # and likewise but on a recent git for test-project-packs2 tar fvzc test-project-packs2.tgz test-project-packs2 =cut Git-PurePerl-0.53/t/checkout/000755 000767 000024 00000000000 12770006122 016412 5ustar00dbrookstaff000000 000000 Git-PurePerl-0.53/t/encoding.t000644 000767 000024 00000001202 12767765163 016602 0ustar00dbrookstaff000000 000000 #!perl use strict; use warnings; use Test::More; use Git::PurePerl; use Test::utf8; my $git = Git::PurePerl->new( directory => "test-encoding" ); for ( [$git->master, "utf-8"], [$git->master->parent, "iso-8859-1"], ) { my ($commit, $encoding) = @{$_}; is( $commit->encoding, $encoding ); for my $role (qw(author committer)) { is_flagged_utf8( $commit->$role->name ); is_sane_utf8( $commit->$role->name ); is( $commit->author->name, "T\x{e9}st User" ); } is_flagged_utf8( $commit->comment ); is_sane_utf8( $commit->comment ); is( $commit->comment, "Touch\x{e9}"); } done_testing; Git-PurePerl-0.53/t/init.t000644 000767 000024 00000015033 12767765163 015766 0ustar00dbrookstaff000000 000000 #!perl use strict; use warnings; use Test::More; use Git::PurePerl; use Path::Class; for my $directory (qw(test-init test-init-bare.git)) { dir($directory)->rmtree; my $git; if ( $directory eq 'test-init-bare.git' ) { $git = Git::PurePerl->init( gitdir => $directory ); } else { $git = Git::PurePerl->init( directory => $directory ); } isa_ok( $git, 'Git::PurePerl', 'can init' ); is( $git->description, 'Unnamed repository; edit this file to name it for gitweb.' ); is( $git->all_sha1s->all, 0, 'does not contain any sha1s' ); is( $git->all_objects->all, 0, 'does not contain any objects' ); my $hello = Git::PurePerl::NewObject::Blob->new( content => 'hello' ); $git->put_object($hello); is( $hello->sha1, 'b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0' ); is( $git->get_object('b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0')->content, 'hello' ); my $there = Git::PurePerl::NewObject::Blob->new( content => 'there' ); $git->put_object($there); is( $there->sha1, 'c78ee1a5bdf46d22da300b68d50bc45c587c3293' ); is( $git->get_object('c78ee1a5bdf46d22da300b68d50bc45c587c3293')->content, 'there' ); my $hello_de = Git::PurePerl::NewDirectoryEntry->new( mode => '100644', filename => 'hello.txt', sha1 => $hello->sha1, ); my $there_de = Git::PurePerl::NewDirectoryEntry->new( mode => '100644', filename => 'there.txt', sha1 => $there->sha1, ); my $tree = Git::PurePerl::NewObject::Tree->new( directory_entries => [ $hello_de, $there_de ] ); is( $tree->sha1, '6d991aebc86bd09e86d74bb84bb9ebfb97e18026' ); $git->put_object($tree); my $tree2 = $git->get_object('6d991aebc86bd09e86d74bb84bb9ebfb97e18026'); is( $tree2->kind, 'tree' ); is( $tree2->size, 74 ); my @directory_entries = $tree2->directory_entries; is( @directory_entries, 2 ); my $directory_entry = $directory_entries[0]; is( $directory_entry->mode, '100644' ); is( $directory_entry->filename, 'hello.txt' ); is( $directory_entry->sha1, 'b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0' ); my $directory_entry2 = $directory_entries[1]; is( $directory_entry2->mode, '100644' ); is( $directory_entry2->filename, 'there.txt' ); is( $directory_entry2->sha1, 'c78ee1a5bdf46d22da300b68d50bc45c587c3293' ); my $actor = Git::PurePerl::Actor->new( name => 'Your Name Comes Here', email => 'you@yourdomain.example.com' ); my $commit = Git::PurePerl::NewObject::Commit->new( tree => $tree->sha1, author => $actor, authored_time => DateTime->from_epoch( epoch => 1240341681 ), committer => $actor, committed_time => DateTime->from_epoch( epoch => 1240341682 ), comment => 'Fix', ); is( $commit->sha1, '860caea5ba298bb4f1df9a80fad84951fcc7db72' ); $git->put_object($commit); my $commit2 = $git->get_object('860caea5ba298bb4f1df9a80fad84951fcc7db72'); is( $commit2->tree_sha1, $tree->sha1 ); isa_ok( $commit2->author, 'Git::PurePerl::Actor' ); is( $commit2->author->name, 'Your Name Comes Here' ); is( $commit2->author->email, 'you@yourdomain.example.com' ); isa_ok( $commit2->committer, 'Git::PurePerl::Actor' ); is( $commit2->committer->name, 'Your Name Comes Here' ); is( $commit2->committer->email, 'you@yourdomain.example.com' ); is( $commit2->authored_time->epoch, 1240341681 ); is( $commit2->committed_time->epoch, 1240341682 ); is( $commit2->comment, 'Fix' ); if ( $directory eq 'test-init-bare.git' ) { $git = Git::PurePerl->new( gitdir => $directory ); } else { $git = Git::PurePerl->new( directory => $directory ); } isa_ok( $git, 'Git::PurePerl', 'can get object' ); is( $git->all_sha1s->all, 4, 'contains four sha1s' ); is( $git->all_objects->all, 4, 'contains four objects' ); my $checkout_directory = dir('t/checkout'); $checkout_directory->rmtree; $checkout_directory->mkpath; unless ( $directory eq 'test-init-bare.git' ) { $git->checkout($checkout_directory); is_deeply( [ sort $checkout_directory->as_foreign('Unix')->children ], [ 't/checkout/hello.txt', 't/checkout/there.txt' ], 'checkout has two files' ); is( file('t/checkout/hello.txt')->slurp, 'hello', 'hello.txt has latest content' ); is( file('t/checkout/there.txt')->slurp, 'there', 'there.txt has latest content' ); } is_deeply( [ $git->ref_names ], ['refs/heads/master'], 'have ref master' ); isa_ok( $git->ref('refs/heads/master'), 'Git::PurePerl::Object::Commit', 'have master commit' ); is( $git->ref('refs/heads/master')->sha1, $commit->sha1, 'master points to our commit' ); my $here = Git::PurePerl::NewObject::Blob->new( content => 'here' ); $git->put_object($here); my $here_de = Git::PurePerl::NewDirectoryEntry->new( mode => '100644', filename => 'there.txt', sha1 => $here->sha1, ); $tree = Git::PurePerl::NewObject::Tree->new( directory_entries => [ $hello_de, $here_de ] ); $git->put_object($tree); my $newcommit = Git::PurePerl::NewObject::Commit->new( tree => $tree->sha1, parent => $commit->sha1, author => $actor, authored_time => DateTime->from_epoch( epoch => 1240341683 ), committer => $actor, committed_time => DateTime->from_epoch( epoch => 1240341684 ), comment => 'Fix again', ); $git->put_object($newcommit); my $newcommit2 = $git->get_object( $newcommit->sha1 ); isa_ok( $newcommit2->author, 'Git::PurePerl::Actor' ); is( $newcommit2->author->name, 'Your Name Comes Here' ); is( $newcommit2->author->email, 'you@yourdomain.example.com' ); isa_ok( $newcommit2->committer, 'Git::PurePerl::Actor' ); is( $newcommit2->committer->name, 'Your Name Comes Here' ); is( $newcommit2->committer->email, 'you@yourdomain.example.com' ); is( $newcommit2->authored_time->epoch, 1240341683 ); is( $newcommit2->committed_time->epoch, 1240341684 ); is( $newcommit2->comment, 'Fix again' ); is( $git->ref('refs/heads/master')->sha1, $newcommit->sha1, 'master updated' ); is( $git->all_sha1s->all, 7, 'contains seven sha1s' ); is( $git->all_objects->all, 7, 'contains seven objects' ); } done_testing; Git-PurePerl-0.53/t/protocol.t000644 000767 000024 00000002434 12767765163 016665 0ustar00dbrookstaff000000 000000 #!perl use strict; use warnings; use Test::More; BEGIN { plan skip_all => 'Needs you to manually run a git daemon'; exit 0; if ( $^O eq 'MSWin32' ) { plan skip_all => 'Windows does NOT have git-daemon yet'; } } use Git::PurePerl; use IO::File; use Path::Class; # git daemon --verbose --reuseaddr --export-all --base-path=/home/acme/git/git-pureperl my $directory = 'test-protocol'; dir($directory)->rmtree; my $git = Git::PurePerl->init( directory => $directory ); isa_ok( $git, 'Git::PurePerl', 'can init' ); $git->clone( 'localhost', '/test-project' ); is( $git->all_sha1s->all, 9 ); is( $git->all_objects->all, 9 ); $git->update_master('0c7b3d23c0f821e58cd20e60d5e63f5ed12ef391'); like( $git->master_sha1, qr/^[a-z0-9]{40}$/ ); my $commit = $git->master; is( $commit->kind, 'commit' ); is( $commit->size, 256 ); like( $commit->sha1, qr/^[a-z0-9]{40}$/ ); is( $commit->tree_sha1, '37b4fcd62571f07408e830f455268891f95cecf5' ); like( $commit->parent_sha1, qr/^[a-z0-9]{40}$/ ); is( $commit->author->name, 'Your Name Comes Here' ); is( $commit->author->email, 'you@yourdomain.example.com' ); is( $commit->committer->name, 'Your Name Comes Here' ); is( $commit->committer->email, 'you@yourdomain.example.com' ); is( $commit->comment, 'add again' ); done_testing; Git-PurePerl-0.53/t/protocol_gpp.t000644 000767 000024 00000001070 12767765163 017526 0ustar00dbrookstaff000000 000000 #!perl use strict; use warnings; use Git::PurePerl; use IO::File; use Path::Class; use Test::More; my $socket = IO::Socket::INET->new("www.github.com:80"); if ($socket) { close ($socket); } else { plan skip_all => 'No Internet connection available'; } my $directory = 'test-protocol'; dir($directory)->rmtree; my $git = Git::PurePerl->init( directory => $directory ); isa_ok( $git, 'Git::PurePerl', 'can init' ); $git->clone( 'github.com', '/acme/git-pureperl.git' ); ok( $git->all_sha1s->all >= 604 ); ok( $git->all_objects->all >= 604 ); done_testing; Git-PurePerl-0.53/t/simple.t000644 000767 000024 00000010621 12767765163 016312 0ustar00dbrookstaff000000 000000 #!perl use strict; use warnings; use Test::More; use Git::PurePerl; use Path::Class; my $checkout_directory = dir('t/checkout'); foreach my $directory (qw(test-project test-project-packs test-project-packs2)) { my $git = Git::PurePerl->new( directory => $directory ); like( $git->master_sha1, qr/^[a-z0-9]{40}$/ ); my $commit = $git->master; is( $commit->kind, 'commit' ); is( $commit->size, 256 ); like( $commit->sha1, qr/^[a-z0-9]{40}$/ ); is( $commit->tree_sha1, '37b4fcd62571f07408e830f455268891f95cecf5' ); like( $commit->parent_sha1, qr/^[a-z0-9]{40}$/ ); isa_ok( $commit->author, 'Git::PurePerl::Actor' ); isa_ok( $commit->committer, 'Git::PurePerl::Actor' ); is( $commit->author->name, 'Your Name Comes Here' ); is( $commit->committer->name, 'Your Name Comes Here' ); isa_ok( $commit->authored_time, 'DateTime' ); is( $commit->authored_time->month, 11 ); is( $commit->comment, 'add again' ); my $tree = $commit->tree; is( $tree->kind, 'tree' ); is( $tree->size, 36 ); my @directory_entries = $tree->directory_entries; is( @directory_entries, 1 ); my $directory_entry = $directory_entries[0]; is( $directory_entry->mode, '100644' ); is( $directory_entry->filename, 'file.txt' ); is( $directory_entry->sha1, '513feba2e53ebbd2532419ded848ba19de88ba00' ); my $blob = $directory_entry->object; is( $blob->kind, 'blob' ); is( $blob->size, 32 ); is( $blob->content, 'hello world! hello world, again ' ); $commit = $commit->parent; is( $commit->kind, 'commit' ); is( $commit->size, 259 ); like( $commit->sha1, qr/^[a-z0-9]{40}$/ ); is( $commit->tree_sha1, 'd0492b368b66bdabf2ac1fd8c92b39d3db916e59' ); like( $commit->parent_sha1, qr/^[a-z0-9]{40}$/ ); is( $commit->author->email, 'you@yourdomain.example.com' ); is( $commit->committer->email, 'you@yourdomain.example.com' ); is( $commit->comment, 'add emphasis' ); $tree = $commit->tree; is( $tree->kind, 'tree' ); is( $tree->size, 36 ); @directory_entries = $tree->directory_entries; is( @directory_entries, 1 ); $directory_entry = $directory_entries[0]; is( $directory_entry->mode, '100644' ); is( $directory_entry->filename, 'file.txt' ); is( $directory_entry->sha1, 'a0423896973644771497bdc03eb99d5281615b51' ); $blob = $directory_entry->object; is( $blob->kind, 'blob' ); is( $blob->size, 13 ); is( $blob->content, 'hello world! ' ); $commit = $commit->parent; is( $commit->kind, 'commit' ); is( $commit->size, 213 ); like( $commit->sha1, qr/^[a-z0-9]{40}$/ ); is( $commit->tree_sha1, '92b8b694ffb1675e5975148e1121810081dbdffe' ); is( $commit->parent_sha1, undef ); is( $commit->parent, undef ); is( $commit->author->name, 'Your Name Comes Here' ); is( $commit->committer->name, 'Your Name Comes Here' ); is( $commit->comment, 'initial commit' ); $tree = $commit->tree; is( $tree->kind, 'tree' ); is( $tree->size, 36 ); @directory_entries = $tree->directory_entries; is( @directory_entries, 1 ); $directory_entry = $directory_entries[0]; is( $directory_entry->mode, '100644' ); is( $directory_entry->filename, 'file.txt' ); is( $directory_entry->sha1, '3b18e512dba79e4c8300dd08aeb37f8e728b8dad' ); $blob = $directory_entry->object; is( $blob->kind, 'blob' ); is( $blob->size, 12 ); is( $blob->content, 'hello world ' ); is( $git->all_sha1s->all, 9 ); is( $git->all_objects->all, 9 ); is( $git->config->get(key => 'user.name'), 'Your Name Comes Here' ); $checkout_directory->rmtree; $checkout_directory->mkpath; $git->checkout($checkout_directory); is_deeply( [ $checkout_directory->as_foreign('Unix')->children ], ['t/checkout/file.txt'], 'checkout has one file' ); is( file('t/checkout/file.txt')->slurp, 'hello world! hello world, again ', 'checkout has latest content' ); is_deeply( [ $git->ref_names ], ['refs/heads/master'], 'have ref names' ); isa_ok( ( $git->refs )[0], 'Git::PurePerl::Object::Commit', 'have refs' ); ok( $git->refs_sha1, 'have refs_sha1' ); ok( $git->ref_sha1('refs/heads/master'), 'have ref_sha1 for master' ); isa_ok( $git->ref('refs/heads/master'), 'Git::PurePerl::Object::Commit', 'have ref master' ); } done_testing; Git-PurePerl-0.53/t/checkout/file.txt000644 000767 000024 00000000040 12767774037 020113 0ustar00dbrookstaff000000 000000 hello world! hello world, again Git-PurePerl-0.53/lib/Git/000755 000767 000024 00000000000 12770006122 015633 5ustar00dbrookstaff000000 000000 Git-PurePerl-0.53/lib/Git/PurePerl/000755 000767 000024 00000000000 12770006122 017371 5ustar00dbrookstaff000000 000000 Git-PurePerl-0.53/lib/Git/PurePerl.pm000644 000767 000024 00000035005 12770000235 017731 0ustar00dbrookstaff000000 000000 package Git::PurePerl; use Moose; use MooseX::StrictConstructor; use MooseX::Types::Path::Class; use Compress::Zlib qw(uncompress); use Data::Stream::Bulk; use Data::Stream::Bulk::Array; use Data::Stream::Bulk::Path::Class; use DateTime; use Digest::SHA; use File::Find::Rule; use Git::PurePerl::Actor; use Git::PurePerl::Config; use Git::PurePerl::DirectoryEntry; use Git::PurePerl::Loose; use Git::PurePerl::Object; use Git::PurePerl::NewDirectoryEntry; use Git::PurePerl::NewObject; use Git::PurePerl::NewObject::Blob; use Git::PurePerl::NewObject::Commit; use Git::PurePerl::NewObject::Tag; use Git::PurePerl::NewObject::Tree; use Git::PurePerl::Object::Tree; use Git::PurePerl::Object::Blob; use Git::PurePerl::Object::Commit; use Git::PurePerl::Object::Tag; use Git::PurePerl::Object::Tree; use Git::PurePerl::Pack; use Git::PurePerl::Pack::WithIndex; use Git::PurePerl::Pack::WithoutIndex; use Git::PurePerl::PackIndex; use Git::PurePerl::PackIndex::Version1; use Git::PurePerl::PackIndex::Version2; use Git::PurePerl::Protocol; use IO::Digest; use IO::Socket::INET; use Path::Class; use namespace::autoclean; our $VERSION = '0.53'; $VERSION = eval $VERSION; has 'directory' => ( is => 'ro', isa => 'Path::Class::Dir', required => 0, coerce => 1 ); has 'gitdir' => ( is => 'ro', isa => 'Path::Class::Dir', required => 1, coerce => 1 ); has 'loose' => ( is => 'rw', isa => 'Git::PurePerl::Loose', required => 0, lazy_build => 1, ); has 'packs' => ( is => 'rw', isa => 'ArrayRef[Git::PurePerl::Pack]', required => 0, auto_deref => 1, lazy_build => 1, ); has 'description' => ( is => 'rw', isa => 'Str', lazy => 1, default => sub { my $self = shift; file( $self->gitdir, 'description' )->slurp( chomp => 1 ); } ); has 'config' => ( is => 'ro', isa => 'Git::PurePerl::Config', lazy => 1, default => sub { my $self = shift; Git::PurePerl::Config->new(git => $self); } ); __PACKAGE__->meta->make_immutable; sub BUILDARGS { my $class = shift; my $params = $class->SUPER::BUILDARGS(@_); $params->{'gitdir'} ||= dir( $params->{'directory'}, '.git' ); return $params; } sub BUILD { my $self = shift; unless ( -d $self->gitdir ) { confess $self->gitdir . ' is not a directory'; } unless ( not defined $self->directory or -d $self->directory ) { confess $self->directory . ' is not a directory'; } } sub _build_loose { my $self = shift; my $loose_dir = dir( $self->gitdir, 'objects' ); return Git::PurePerl::Loose->new( directory => $loose_dir ); } sub _build_packs { my $self = shift; my $pack_dir = dir( $self->gitdir, 'objects', 'pack' ); my @packs; foreach my $filename ( $pack_dir->children ) { next unless $filename =~ /\.pack$/; push @packs, Git::PurePerl::Pack::WithIndex->new( filename => $filename ); } return \@packs; } sub _ref_names_recursive { my ( $dir, $base, $names ) = @_; foreach my $file ( $dir->children ) { if ( -d $file ) { my $reldir = $file->relative($dir); my $subbase = $base . $reldir . "/"; _ref_names_recursive( $file, $subbase, $names ); } else { push @$names, $base . $file->basename; } } } sub ref_names { my $self = shift; my @names; foreach my $type (qw(heads remotes tags)) { my $dir = dir( $self->gitdir, 'refs', $type ); next unless -d $dir; my $base = "refs/$type/"; _ref_names_recursive( $dir, $base, \@names ); } my $packed_refs = file( $self->gitdir, 'packed-refs' ); if ( -f $packed_refs ) { foreach my $line ( $packed_refs->slurp( chomp => 1 ) ) { next if $line =~ /^#/; next if $line =~ /^\^/; my ( $sha1, $name ) = split ' ', $line; push @names, $name; } } return @names; } sub refs_sha1 { my $self = shift; return map { $self->ref_sha1($_) } $self->ref_names; } sub refs { my $self = shift; return map { $self->ref($_) } $self->ref_names; } sub ref_sha1 { my ( $self, $wantref ) = @_; my $dir = dir( $self->gitdir, 'refs' ); return unless -d $dir; if ($wantref eq "HEAD") { my $file = file($self->gitdir, 'HEAD'); my $sha1 = file($file)->slurp || confess("Error reading $file: $!"); chomp $sha1; return _ensure_sha1_is_sha1( $self, $sha1 ); } foreach my $file ( File::Find::Rule->new->file->in($dir) ) { my $ref = 'refs/' . file($file)->relative($dir)->as_foreign('Unix'); if ( $ref eq $wantref ) { my $sha1 = file($file)->slurp || confess("Error reading $file: $!"); chomp $sha1; return _ensure_sha1_is_sha1( $self, $sha1 ); } } my $packed_refs = file( $self->gitdir, 'packed-refs' ); if ( -f $packed_refs ) { my $last_name; my $last_sha1; foreach my $line ( $packed_refs->slurp( chomp => 1 ) ) { next if $line =~ /^#/; my ( $sha1, $name ) = split ' ', $line; $sha1 =~ s/^\^//; $name ||= $last_name; return _ensure_sha1_is_sha1( $self, $last_sha1 ) if $last_name and $last_name eq $wantref and $name ne $wantref; $last_name = $name; $last_sha1 = $sha1; } return _ensure_sha1_is_sha1( $self, $last_sha1 ) if $last_name eq $wantref; } return undef; } sub _ensure_sha1_is_sha1 { my ( $self, $sha1 ) = @_; return $self->ref_sha1($1) if $sha1 =~ /^ref: (.*)/; return $sha1; } sub ref { my ( $self, $wantref ) = @_; return $self->get_object( $self->ref_sha1($wantref) ); } sub master_sha1 { my $self = shift; return $self->ref_sha1('refs/heads/master'); } sub master { my $self = shift; return $self->ref('refs/heads/master'); } sub head_sha1 { my $self = shift; return $self->ref_sha1('HEAD'); } sub head { my $self = shift; return $self->ref('HEAD'); } sub get_object { my ( $self, $sha1 ) = @_; return unless $sha1; return $self->get_object_packed($sha1) || $self->get_object_loose($sha1); } sub get_objects { my ( $self, @sha1s ) = @_; return map { $self->get_object($_) } @sha1s; } sub get_object_packed { my ( $self, $sha1 ) = @_; foreach my $pack ( $self->packs ) { my ( $kind, $size, $content ) = $pack->get_object($sha1); if ( defined($kind) && defined($size) && defined($content) ) { return $self->create_object( $sha1, $kind, $size, $content ); } } } sub get_object_loose { my ( $self, $sha1 ) = @_; my ( $kind, $size, $content ) = $self->loose->get_object($sha1); if ( defined($kind) && defined($size) && defined($content) ) { return $self->create_object( $sha1, $kind, $size, $content ); } } sub create_object { my ( $self, $sha1, $kind, $size, $content ) = @_; if ( $kind eq 'commit' ) { return Git::PurePerl::Object::Commit->new( sha1 => $sha1, kind => $kind, size => $size, content => $content, git => $self, ); } elsif ( $kind eq 'tree' ) { return Git::PurePerl::Object::Tree->new( sha1 => $sha1, kind => $kind, size => $size, content => $content, git => $self, ); } elsif ( $kind eq 'blob' ) { return Git::PurePerl::Object::Blob->new( sha1 => $sha1, kind => $kind, size => $size, content => $content, git => $self, ); } elsif ( $kind eq 'tag' ) { return Git::PurePerl::Object::Tag->new( sha1 => $sha1, kind => $kind, size => $size, content => $content, git => $self, ); } else { confess "unknown kind $kind: $content"; } } sub all_sha1s { my $self = shift; my $dir = dir( $self->gitdir, 'objects' ); my @streams; push @streams, $self->loose->all_sha1s; foreach my $pack ( $self->packs ) { push @streams, $pack->all_sha1s; } return Data::Stream::Bulk::Cat->new( streams => \@streams ); } sub all_objects { my $self = shift; my $stream = $self->all_sha1s; return Data::Stream::Bulk::Filter->new( filter => sub { return [ $self->get_objects(@$_) ] }, stream => $stream, ); } sub put_object { my ( $self, $object, $ref ) = @_; $self->loose->put_object($object); if ( $object->kind eq 'commit' ) { $ref = 'master' unless $ref; $self->update_ref( $ref, $object->sha1 ); } } sub update_ref { my ( $self, $refname, $sha1 ) = @_; my $ref = file( $self->gitdir, 'refs', 'heads', $refname ); $ref->parent->mkpath; my $ref_fh = $ref->openw; $ref_fh->print($sha1) || die "Error writing to $ref"; # FIXME is this always what we want? my $head = file( $self->gitdir, 'HEAD' ); my $head_fh = $head->openw; $head_fh->print("ref: refs/heads/$refname") || die "Error writing to $head"; } sub init { my ( $class, %arguments ) = @_; my $directory = $arguments{directory}; my $git_dir; unless ( defined $directory ) { $git_dir = $arguments{gitdir} || confess "init() needs either a 'directory' or a 'gitdir' argument"; } else { if ( not defined $arguments{gitdir} ) { $git_dir = $arguments{gitdir} = dir( $directory, '.git' ); } dir($directory)->mkpath; } dir($git_dir)->mkpath; dir( $git_dir, 'refs', 'tags' )->mkpath; dir( $git_dir, 'objects', 'info' )->mkpath; dir( $git_dir, 'objects', 'pack' )->mkpath; dir( $git_dir, 'branches' )->mkpath; dir( $git_dir, 'hooks' )->mkpath; my $bare = defined($directory) ? 'false' : 'true'; $class->_add_file( file( $git_dir, 'config' ), "[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = $bare\n\tlogallrefupdates = true\n" ); $class->_add_file( file( $git_dir, 'description' ), "Unnamed repository; edit this file to name it for gitweb.\n" ); $class->_add_file( file( $git_dir, 'hooks', 'applypatch-msg' ), "# add shell script and make executable to enable\n" ); $class->_add_file( file( $git_dir, 'hooks', 'post-commit' ), "# add shell script and make executable to enable\n" ); $class->_add_file( file( $git_dir, 'hooks', 'post-receive' ), "# add shell script and make executable to enable\n" ); $class->_add_file( file( $git_dir, 'hooks', 'post-update' ), "# add shell script and make executable to enable\n" ); $class->_add_file( file( $git_dir, 'hooks', 'pre-applypatch' ), "# add shell script and make executable to enable\n" ); $class->_add_file( file( $git_dir, 'hooks', 'pre-commit' ), "# add shell script and make executable to enable\n" ); $class->_add_file( file( $git_dir, 'hooks', 'pre-rebase' ), "# add shell script and make executable to enable\n" ); $class->_add_file( file( $git_dir, 'hooks', 'update' ), "# add shell script and make executable to enable\n" ); dir( $git_dir, 'info' )->mkpath; $class->_add_file( file( $git_dir, 'info', 'exclude' ), "# *.[oa]\n# *~\n" ); return $class->new(%arguments); } sub checkout { my ( $self, $directory, $tree ) = @_; $directory ||= $self->directory; $tree ||= $self->master->tree; confess("Missing tree") unless $tree; foreach my $directory_entry ( $tree->directory_entries ) { my $filename = file( $directory, $directory_entry->filename ); my $sha1 = $directory_entry->sha1; my $mode = $directory_entry->mode; my $object = $self->get_object($sha1); if ( $object->kind eq 'blob' ) { $self->_add_file( $filename, $object->content ); chmod( oct( '0' . $mode ), $filename ) || die "Error chmoding $filename to $mode: $!"; } elsif ( $object->kind eq 'tree' ) { dir($filename)->mkpath; $self->checkout( $filename, $object ); } else { die $object->kind; } } } sub clone { my $self = shift; my $remote; if (@_ == 2) { # For backwards compatibility $remote = "git://$_[0]"; $remote .= "/" unless $_[1] =~ m{^/}; $remote .= $_[1]; } else { $remote = shift; } my $protocol = Git::PurePerl::Protocol->new( remote => $remote, ); my $sha1s = $protocol->connect; my $head = $sha1s->{HEAD}; my $data = $protocol->fetch_pack($head); my $filename = file( $self->gitdir, 'objects', 'pack', 'pack-' . $head . '.pack' ); $self->_add_file( $filename, $data ); my $pack = Git::PurePerl::Pack::WithoutIndex->new( filename => $filename ); $pack->create_index(); $self->update_ref( master => $head ); } sub _add_file { my ( $class, $filename, $contents ) = @_; my $fh = $filename->openw || confess "Error opening to $filename: $!"; binmode($fh); #important for Win32 $fh->print($contents) || confess "Error writing to $filename: $!"; $fh->close || confess "Error closing $filename: $!"; } 1; __END__ =head1 NAME Git::PurePerl - A Pure Perl interface to Git repositories =head1 SYNOPSIS my $git = Git::PurePerl->new( directory => '/path/to/git/' ); $git->master->committer; $git->master->comment; $git->get_object($git->master->tree); =head1 DESCRIPTION This module is a Pure Perl interface to Git repositories. It was mostly based on Grit L. =head1 METHODS =over 4 =item master =item get_object =item get_object_packed =item get_object_loose =item create_object =item all_sha1s =back =head1 MAINTAINANCE This module is maintained in git at L. Patches are welcome, please come speak to one of the L team on C<< #gitalist >>. =head1 AUTHOR Leon Brocard =head1 CONTRIBUTORS =over 4 =item Chris Reinhardt =item Tomas (t0m) Doran =item Dan (broquaint) Brook =item Alex Vandiver =item Dagfinn Ilmari MannsEker =back =head1 COPYRIGHT Copyright (C) 2008, Leon Brocard and the above mentioned contributors. =head1 LICENSE This module is free software; you can redistribute it or modify it under the same terms as Perl itself. =cut Git-PurePerl-0.53/lib/Git/PurePerl/Actor.pm000644 000767 000024 00000000445 12767765163 021031 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Actor; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use namespace::autoclean; has 'name' => ( is => 'ro', isa => 'Str', required => 1 ); has 'email' => ( is => 'ro', isa => 'Str', required => 1 ); __PACKAGE__->meta->make_immutable; 1; Git-PurePerl-0.53/lib/Git/PurePerl/Config.pm000644 000767 000024 00000000622 12767765163 021163 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Config; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use namespace::autoclean; extends 'Config::GitLike'; has '+confname' => ( default => "gitconfig" ); has 'git' => ( is => 'ro', isa => 'Git::PurePerl', required => 1, weak_ref => 1 ); override dir_file => sub { my $self = shift; return $self->git->gitdir->file("config"); }; 1; Git-PurePerl-0.53/lib/Git/PurePerl/DirectoryEntry.pm000644 000767 000024 00000001076 12767765163 022750 0ustar00dbrookstaff000000 000000 package Git::PurePerl::DirectoryEntry; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use namespace::autoclean; has 'mode' => ( is => 'ro', isa => 'Str', required => 1 ); has 'filename' => ( is => 'ro', isa => 'Str', required => 1 ); has 'sha1' => ( is => 'ro', isa => 'Str', required => 1 ); has 'git' => ( is => 'ro', isa => 'Git::PurePerl', required => 1, weak_ref => 1 ); sub object { my $self = shift; return $self->git->get_object( $self->sha1 ); } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/lib/Git/PurePerl/Loose.pm000644 000767 000024 00000003044 12767765163 021040 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Loose; use Moose; use MooseX::StrictConstructor; use MooseX::Types::Path::Class; use Compress::Zlib qw(compress uncompress); use Path::Class; use namespace::autoclean; has 'directory' => ( is => 'ro', isa => 'Path::Class::Dir', required => 1, coerce => 1 ); sub get_object { my ( $self, $sha1 ) = @_; my $filename = file( $self->directory, substr( $sha1, 0, 2 ), substr( $sha1, 2 ) ); return unless -f $filename; my $compressed = $filename->slurp( iomode => '<:raw' ); my $data = uncompress($compressed); my ( $kind, $size, $content ) = $data =~ /^(\w+) (\d+)\0(.*)$/s; return ( $kind, $size, $content ); } sub put_object { my ( $self, $object ) = @_; my $filename = file( $self->directory, substr( $object->sha1, 0, 2 ), substr( $object->sha1, 2 ) ); $filename->parent->mkpath; my $compressed = compress( $object->raw ); my $fh = $filename->openw; binmode($fh); #important for Win32 $fh->print($compressed) || die "Error writing to $filename: $!"; } sub all_sha1s { my $self = shift; my $files = Data::Stream::Bulk::Path::Class->new( dir => $self->directory, only_files => 1, ); return Data::Stream::Bulk::Filter->new( filter => sub { [ map { m{([a-z0-9]{2})[/\\]([a-z0-9]{38})}; $1 . $2 } grep {m{[/\\][a-z0-9]{2}[/\\]}} @$_ ]; }, stream => $files, ); } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/lib/Git/PurePerl/NewDirectoryEntry.pm000644 000767 000024 00000000624 12767765163 023420 0ustar00dbrookstaff000000 000000 package Git::PurePerl::NewDirectoryEntry; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use namespace::autoclean; has 'mode' => ( is => 'ro', isa => 'Str', required => 1 ); has 'filename' => ( is => 'ro', isa => 'Str', required => 1 ); has 'sha1' => ( is => 'ro', isa => 'Str', required => 1 ); __PACKAGE__->meta->make_immutable; 1; Git-PurePerl-0.53/lib/Git/PurePerl/NewObject/000755 000767 000024 00000000000 12770006122 021251 5ustar00dbrookstaff000000 000000 Git-PurePerl-0.53/lib/Git/PurePerl/NewObject.pm000644 000767 000024 00000001545 12767765163 021643 0ustar00dbrookstaff000000 000000 package Git::PurePerl::NewObject; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use namespace::autoclean; enum 'ObjectKind' => [qw(commit tree blob tag)]; has 'kind' => ( is => 'ro', isa => 'ObjectKind', required => 1 ); has 'size' => ( is => 'ro', isa => 'Int', required => 0, lazy_build => 1 ); has 'content' => ( is => 'rw', isa => 'Str', required => 0, lazy_build => 1 ); has 'sha1' => ( is => 'ro', isa => 'Str', required => 0, lazy_build => 1 ); sub _build_sha1 { my $self = shift; my $sha1 = Digest::SHA->new; $sha1->add( $self->raw ); my $sha1_hex = $sha1->hexdigest; return $sha1_hex; } sub _build_size { my $self = shift; return length $self->content; } sub raw { my $self = shift; return $self->kind . ' ' . $self->size . "\0" . $self->content; } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/lib/Git/PurePerl/Object/000755 000767 000024 00000000000 12770006122 020577 5ustar00dbrookstaff000000 000000 Git-PurePerl-0.53/lib/Git/PurePerl/Object.pm000644 000767 000024 00000001127 12767765163 021165 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Object; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use namespace::autoclean; enum 'ObjectKind' => [qw(commit tree blob tag)]; has 'kind' => ( is => 'ro', isa => 'ObjectKind', required => 1 ); has 'size' => ( is => 'ro', isa => 'Int', required => 1 ); has 'content' => ( is => 'rw', isa => 'Str', required => 1 ); has 'sha1' => ( is => 'ro', isa => 'Str', required => 1 ); has 'git' => ( is => 'ro', isa => 'Git::PurePerl', required => 1, weak_ref => 1 ); __PACKAGE__->meta->make_immutable; 1; Git-PurePerl-0.53/lib/Git/PurePerl/Pack/000755 000767 000024 00000000000 12770006122 020247 5ustar00dbrookstaff000000 000000 Git-PurePerl-0.53/lib/Git/PurePerl/Pack.pm000644 000767 000024 00000013346 12767765163 020643 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Pack; use Moose; use MooseX::StrictConstructor; use MooseX::Types::Path::Class; use Compress::Raw::Zlib; use IO::File; use namespace::autoclean; has 'filename' => ( is => 'ro', isa => 'Path::Class::File', required => 1, coerce => 1 ); has 'fh' => ( is => 'rw', isa => 'IO::File', required => 0, lazy_build => 1 ); my @TYPES = ( 'none', 'commit', 'tree', 'blob', 'tag', '', 'ofs_delta', 'ref_delta' ); my $OBJ_NONE = 0; my $OBJ_COMMIT = 1; my $OBJ_TREE = 2; my $OBJ_BLOB = 3; my $OBJ_TAG = 4; my $OBJ_OFS_DELTA = 6; my $OBJ_REF_DELTA = 7; my $SHA1Size = 20; sub _build_fh { my $self = shift; my $fh = IO::File->new( $self->filename ) || confess($!); $fh->binmode(); return $fh; } sub all_sha1s { my ( $self, $want_sha1 ) = @_; return Data::Stream::Bulk::Array->new( array => [ $self->index->all_sha1s ] ); } sub unpack_object { my ( $self, $offset ) = @_; my $obj_offset = $offset; my $fh = $self->fh; $fh->seek( $offset, 0 ) || die "Error seeking in pack: $!"; $fh->read( my $c, 1 ) || die "Error reading from pack: $!"; $c = unpack( 'C', $c ) || die $!; my $size = ( $c & 0xf ); my $type_number = ( $c >> 4 ) & 7; my $type = $TYPES[$type_number] || confess "invalid type $type_number"; my $shift = 4; $offset++; while ( ( $c & 0x80 ) != 0 ) { $fh->read( $c, 1 ) || die $!; $c = unpack( 'C', $c ) || die $!; $size |= ( ( $c & 0x7f ) << $shift ); $shift += 7; $offset += 1; } if ( $type eq 'ofs_delta' || $type eq 'ref_delta' ) { ( $type, $size, my $content ) = $self->unpack_deltified( $type, $offset, $obj_offset, $size ); return ( $type, $size, $content ); } elsif ( $type eq 'commit' || $type eq 'tree' || $type eq 'blob' || $type eq 'tag' ) { my $content = $self->read_compressed( $offset, $size ); return ( $type, $size, $content ); } else { confess "invalid type $type"; } } sub read_compressed { my ( $self, $offset, $size ) = @_; my $fh = $self->fh; $fh->seek( $offset, 0 ) || die $!; my ( $deflate, $status ) = Compress::Raw::Zlib::Inflate->new( -AppendOutput => 1, -ConsumeInput => 0 ); my $out = ""; while ( length($out) < $size ) { $fh->read( my $block, 4096 ) || die $!; my $status = $deflate->inflate( $block, $out ); } confess length($out)." is not $size" unless length($out) == $size; $fh->seek( $offset + $deflate->total_in, 0 ) || die $!; return $out; } sub unpack_deltified { my ( $self, $type, $offset, $obj_offset, $size ) = @_; my $fh = $self->fh; my $base; $fh->seek( $offset, 0 ) || die $!; $fh->read( my $data, $SHA1Size ) || die $!; my $sha1 = unpack( 'H*', $data ); if ( $type eq 'ofs_delta' ) { my $i = 0; my $c = unpack( 'C', substr( $data, $i, 1 ) ); my $base_offset = $c & 0x7f; while ( ( $c & 0x80 ) != 0 ) { $c = unpack( 'C', substr( $data, ++$i, 1 ) ); $base_offset++; $base_offset <<= 7; $base_offset |= $c & 0x7f; } $base_offset = $obj_offset - $base_offset; $offset += $i + 1; ( $type, undef, $base ) = $self->unpack_object($base_offset); } else { ( $type, undef, $base ) = $self->get_object($sha1); $offset += $SHA1Size; } my $delta = $self->read_compressed( $offset, $size ); my $new = $self->patch_delta( $base, $delta ); return ( $type, length($new), $new ); } sub patch_delta { my ( $self, $base, $delta ) = @_; my ( $src_size, $pos ) = $self->patch_delta_header_size( $delta, 0 ); if ( $src_size != length($base) ) { confess "invalid delta data"; } ( my $dest_size, $pos ) = $self->patch_delta_header_size( $delta, $pos ); my $dest = ""; while ( $pos < length($delta) ) { my $c = substr( $delta, $pos, 1 ); $c = unpack( 'C', $c ); $pos++; if ( ( $c & 0x80 ) != 0 ) { my $cp_off = 0; my $cp_size = 0; $cp_off = unpack( 'C', substr( $delta, $pos++, 1 ) ) if ( $c & 0x01 ) != 0; $cp_off |= unpack( 'C', substr( $delta, $pos++, 1 ) ) << 8 if ( $c & 0x02 ) != 0; $cp_off |= unpack( 'C', substr( $delta, $pos++, 1 ) ) << 16 if ( $c & 0x04 ) != 0; $cp_off |= unpack( 'C', substr( $delta, $pos++, 1 ) ) << 24 if ( $c & 0x08 ) != 0; $cp_size = unpack( 'C', substr( $delta, $pos++, 1 ) ) if ( $c & 0x10 ) != 0; $cp_size |= unpack( 'C', substr( $delta, $pos++, 1 ) ) << 8 if ( $c & 0x20 ) != 0; $cp_size |= unpack( 'C', substr( $delta, $pos++, 1 ) ) << 16 if ( $c & 0x40 ) != 0; $cp_size = 0x10000 if $cp_size == 0; $dest .= substr( $base, $cp_off, $cp_size ); } elsif ( $c != 0 ) { $dest .= substr( $delta, $pos, $c ); $pos += $c; } else { confess 'invalid delta data'; } } if ( length($dest) != $dest_size ) { confess 'invalid delta data'; } return $dest; } sub patch_delta_header_size { my ( $self, $delta, $pos ) = @_; my $size = 0; my $shift = 0; while (1) { my $c = substr( $delta, $pos, 1 ); unless ( defined $c ) { confess 'invalid delta header'; } $c = unpack( 'C', $c ); $pos++; $size |= ( $c & 0x7f ) << $shift; $shift += 7; last if ( $c & 0x80 ) == 0; } return ( $size, $pos ); } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/lib/Git/PurePerl/PackIndex/000755 000767 000024 00000000000 12770006121 021236 5ustar00dbrookstaff000000 000000 Git-PurePerl-0.53/lib/Git/PurePerl/PackIndex.pm000644 000767 000024 00000002445 12767765163 021631 0ustar00dbrookstaff000000 000000 package Git::PurePerl::PackIndex; use Moose; use MooseX::StrictConstructor; use IO::File; use namespace::autoclean; has 'filename' => ( is => 'ro', isa => 'Path::Class::File', required => 1, coerce => 1 ); has 'fh' => ( is => 'rw', isa => 'IO::File', required => 0 ); has 'offsets' => ( is => 'rw', isa => 'ArrayRef[Int]', required => 0, auto_deref => 1, ); has 'size' => ( is => 'rw', isa => 'Int', required => 0 ); my $FanOutCount = 256; my $SHA1Size = 20; my $IdxOffsetSize = 4; my $OffsetSize = 4; my $CrcSize = 4; my $OffsetStart = $FanOutCount * $IdxOffsetSize; my $SHA1Start = $OffsetStart + $OffsetSize; my $EntrySize = $OffsetSize + $SHA1Size; my $EntrySizeV2 = $SHA1Size + $CrcSize + $OffsetSize; sub BUILD { my $self = shift; my $filename = $self->filename; my $fh = IO::File->new($filename) || confess($!); $self->fh($fh); my @offsets = (0); $fh->seek( $self->global_offset, 0 ); foreach my $i ( 0 .. $FanOutCount - 1 ) { $fh->read( my $data, $IdxOffsetSize ); my $offset = unpack( 'N', $data ); confess("pack has discontinuous index") if $offset < $offsets[-1]; push @offsets, $offset; } $self->offsets( \@offsets ); $self->size( $offsets[-1] ); } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/lib/Git/PurePerl/Protocol/000755 000767 000024 00000000000 12770006122 021172 5ustar00dbrookstaff000000 000000 Git-PurePerl-0.53/lib/Git/PurePerl/Protocol.pm000644 000767 000024 00000006511 12767765163 021562 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Protocol; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use namespace::autoclean; use Git::PurePerl::Protocol::Git; use Git::PurePerl::Protocol::SSH; use Git::PurePerl::Protocol::File; has 'remote' => ( is => 'ro', isa => 'Str', required => 1 ); has 'read_socket' => ( is => 'rw', required => 0 ); has 'write_socket' => ( is => 'rw', required => 0 ); sub connect { my $self = shift; if ($self->remote =~ m{^git://(.*?@)?(.*?)(/.*)}) { Git::PurePerl::Protocol::Git->meta->rebless_instance( $self, hostname => $2, project => $3, ); } elsif ($self->remote =~ m{^file://(/.*)}) { Git::PurePerl::Protocol::File->meta->rebless_instance( $self, path => $1, ); } elsif ($self->remote =~ m{^ssh://(?:(.*?)@)?(.*?)(/.*)} or $self->remote =~ m{^(?:(.*?)@)?(.*?):(.*)}) { Git::PurePerl::Protocol::SSH->meta->rebless_instance( $self, $1 ? (username => $1) : (), hostname => $2, path => $3, ); } $self->connect_socket; my %sha1s; while ( my $line = $self->read_line() ) { # warn "S $line"; my ( $sha1, $name ) = $line =~ /^([a-z0-9]+) ([^\0\n]+)/; #use YAML; warn Dump $line; $sha1s{$name} = $sha1; } return \%sha1s; } sub fetch_pack { my ( $self, $sha1 ) = @_; $self->send_line("want $sha1 side-band-64k\n"); #send_line( # "want 0c7b3d23c0f821e58cd20e60d5e63f5ed12ef391 multi_ack side-band-64k ofs-delta\n" #); $self->send_line(''); $self->send_line('done'); my $pack; while ( my $line = $self->read_line() ) { if ( $line =~ s/^\x02// ) { print $line; } elsif ( $line =~ /^NAK\n/ ) { } elsif ( $line =~ s/^\x01// ) { $pack .= $line; } else { die "Unknown line: $line"; } #say "s $line"; } return $pack; } sub send_line { my ( $self, $line ) = @_; my $length = length($line); if ( $length == 0 ) { } else { $length += 4; } #warn "length $length"; my $prefix = sprintf( "%04X", $length ); my $text = $prefix . $line; # warn "$text"; $self->write_socket->print($text) || die $!; } sub read { my $self = shift; my $len = shift; my $ret = ""; use bytes; while (1) { my $got = $self->read_socket->read( my $data, $len - length($ret)); if (not defined $got) { die "error: $!"; } elsif ( $got == 0) { die "EOF" } $ret .= $data; if (length($ret) == $len) { return $ret; } } } sub read_line { my $self = shift; my $socket = $self->read_socket; my $prefix = $self->read( 4 ); return if $prefix eq '0000'; # warn "read prefix [$prefix]"; my $len = 0; foreach my $n ( 0 .. 3 ) { my $c = substr( $prefix, $n, 1 ); $len <<= 4; if ( $c ge '0' && $c le '9' ) { $len += ord($c) - ord('0'); } elsif ( $c ge 'a' && $c le 'f' ) { $len += ord($c) - ord('a') + 10; } elsif ( $c ge 'A' && $c le 'F' ) { $len += ord($c) - ord('A') + 10; } } return $self->read( $len - 4 ); } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/lib/Git/PurePerl/Protocol/File.pm000644 000767 000024 00000001037 12767765163 022437 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Protocol::File; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use IPC::Open2; use namespace::autoclean; extends 'Git::PurePerl::Protocol'; has 'path' => ( is => 'ro', isa => 'Str', required => 1 ); sub connect_socket { my $self = shift; my ($read, $write); my $pid = open2( $read, $write, "git-upload-pack", $self->path, ); $read->autoflush(1); $write->autoflush(1); $self->read_socket($read); $self->write_socket($write); } 1; Git-PurePerl-0.53/lib/Git/PurePerl/Protocol/Git.pm000644 000767 000024 00000001560 12767765163 022304 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Protocol::Git; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use namespace::autoclean; extends 'Git::PurePerl::Protocol'; has 'hostname' => ( is => 'ro', isa => 'Str', required => 1 ); has 'port' => ( is => 'ro', isa => 'Int', required => 0, default => 9418 ); has 'project' => ( is => 'rw', isa => 'Str', required => 1 ); sub connect_socket { my $self = shift; my $socket = IO::Socket::INET->new( PeerAddr => $self->hostname, PeerPort => $self->port, Proto => 'tcp' ) || die $! . ' ' . $self->hostname . ':' . $self->port; $socket->autoflush(1) || die $!; $self->read_socket($socket); $self->write_socket($socket); $self->send_line( "git-upload-pack " . $self->project . "\0host=" . $self->hostname . "\0" ); } 1; Git-PurePerl-0.53/lib/Git/PurePerl/Protocol/SSH.pm000644 000767 000024 00000001432 12767765163 022214 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Protocol::SSH; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use IPC::Open2; use namespace::autoclean; extends 'Git::PurePerl::Protocol'; has 'hostname' => ( is => 'ro', isa => 'Str', required => 1 ); has 'username' => ( is => 'ro', isa => 'Str', required => 0 ); has 'path' => ( is => 'ro', isa => 'Str', required => 1 ); sub connect_socket { my $self = shift; my ($read, $write); my $connect = join('@', grep {defined} $self->username, $self->hostname); my $pid = open2( $read, $write, "ssh", $connect, "-o", "BatchMode yes", "git-upload-pack", $self->path, ); $read->autoflush(1); $write->autoflush(1); $self->read_socket($read); $self->write_socket($write); } 1; Git-PurePerl-0.53/lib/Git/PurePerl/PackIndex/Version1.pm000644 000767 000024 00000003634 12767765163 023340 0ustar00dbrookstaff000000 000000 package Git::PurePerl::PackIndex::Version1; use Moose; use MooseX::StrictConstructor; use namespace::autoclean; extends 'Git::PurePerl::PackIndex'; my $FanOutCount = 256; my $SHA1Size = 20; my $IdxOffsetSize = 4; my $OffsetSize = 4; my $CrcSize = 4; my $OffsetStart = $FanOutCount * $IdxOffsetSize; my $SHA1Start = $OffsetStart + $OffsetSize; my $EntrySize = $OffsetSize + $SHA1Size; my $EntrySizeV2 = $SHA1Size + $CrcSize + $OffsetSize; sub global_offset { return 0; } sub all_sha1s { my ( $self, $want_sha1 ) = @_; my $fh = $self->fh; my @sha1s; my $pos = $OffsetStart; $fh->seek( $pos, 0 ) || die $!; foreach my $i ( 1 .. $self->size ) { $fh->read( my $data, $OffsetSize ) || die $!; my $offset = unpack( 'N', $data ); $fh->read( $data, $SHA1Size ) || die $!; my $sha1 = unpack( 'H*', $data ); push @sha1s, $sha1; $pos += $EntrySize; } return @sha1s; } sub get_object_offset { my ( $self, $want_sha1 ) = @_; my @offsets = $self->offsets; my $fh = $self->fh; my $slot = unpack( 'C', pack( 'H*', $want_sha1 ) ); return unless defined $slot; my ( $first, $last ) = @offsets[ $slot, $slot + 1 ]; while ( $first < $last ) { my $mid = int( ( $first + $last ) / 2 ); $fh->seek( $SHA1Start + $mid * $EntrySize, 0 ) || die $!; $fh->read( my $data, $SHA1Size ) || die $!; my $midsha1 = unpack( 'H*', $data ); if ( $midsha1 lt $want_sha1 ) { $first = $mid + 1; } elsif ( $midsha1 gt $want_sha1 ) { $last = $mid; } else { my $pos = $OffsetStart + $mid * $EntrySize; $fh->seek( $pos, 0 ) || die $!; $fh->read( my $data, $OffsetSize ) || die $!; my $offset = unpack( 'N', $data ); return $offset; } } return; } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/lib/Git/PurePerl/PackIndex/Version2.pm000644 000767 000024 00000005140 12767765163 023333 0ustar00dbrookstaff000000 000000 package Git::PurePerl::PackIndex::Version2; use Moose; use MooseX::StrictConstructor; use namespace::autoclean; extends 'Git::PurePerl::PackIndex'; my $FanOutCount = 256; my $SHA1Size = 20; my $IdxOffsetSize = 4; my $OffsetSize = 4; my $CrcSize = 4; my $OffsetStart = $FanOutCount * $IdxOffsetSize; my $SHA1Start = $OffsetStart + $OffsetSize; my $EntrySize = $OffsetSize + $SHA1Size; my $EntrySizeV2 = $SHA1Size + $CrcSize + $OffsetSize; sub global_offset { return 8; } sub all_sha1s { my ( $self, $want_sha1 ) = @_; my $fh = $self->fh; my @sha1s; my @data; my $pos = $OffsetStart; $fh->seek( $pos + $self->global_offset, 0 ) || die $!; foreach my $i ( 0 .. $self->size - 1 ) { $fh->read( my $sha1, $SHA1Size ) || die $!; $data[$i] = [ unpack( 'H*', $sha1 ), 0, 0 ]; $pos += $SHA1Size; } $fh->seek( $pos + $self->global_offset, 0 ) || die $!; foreach my $i ( 0 .. $self->size - 1 ) { $fh->read( my $crc, $CrcSize ) || die $!; $data[$i]->[1] = unpack( 'H*', $crc ); $pos += $CrcSize; } $fh->seek( $pos + $self->global_offset, 0 ) || die $!; foreach my $i ( 0 .. $self->size - 1 ) { $fh->read( my $offset, $OffsetSize ) || die $!; $data[$i]->[2] = unpack( 'N', $offset ); $pos += $OffsetSize; } foreach my $data (@data) { my ( $sha1, $crc, $offset ) = @$data; push @sha1s, $sha1; } return @sha1s; } sub get_object_offset { my ( $self, $want_sha1 ) = @_; my @offsets = $self->offsets; my $fh = $self->fh; my $slot = unpack( 'C', pack( 'H*', $want_sha1 ) ); return unless defined $slot; my ( $first, $last ) = @offsets[ $slot, $slot + 1 ]; while ( $first < $last ) { my $mid = int( ( $first + $last ) / 2 ); $fh->seek( $self->global_offset + $OffsetStart + ( $mid * $SHA1Size ), 0 ) || die $!; $fh->read( my $data, $SHA1Size ) || die $!; my $midsha1 = unpack( 'H*', $data ); if ( $midsha1 lt $want_sha1 ) { $first = $mid + 1; } elsif ( $midsha1 gt $want_sha1 ) { $last = $mid; } else { my $pos = $self->global_offset + $OffsetStart + ( $self->size * ( $SHA1Size + $CrcSize ) ) + ( $mid * $OffsetSize ); $fh->seek( $pos, 0 ) || die $!; $fh->read( my $data, $OffsetSize ) || die $!; my $offset = unpack( 'N', $data ); return $offset; } } return; } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/lib/Git/PurePerl/Pack/WithIndex.pm000644 000767 000024 00000002603 12767765163 022540 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Pack::WithIndex; use Moose; use MooseX::StrictConstructor; use namespace::autoclean; extends 'Git::PurePerl::Pack'; has 'index_filename' => ( is => 'rw', isa => 'Path::Class::File', required => 0, coerce => 1 ); has 'index' => ( is => 'rw', isa => 'Git::PurePerl::PackIndex', required => 0 ); sub BUILD { my $self = shift; my $index_filename = $self->filename; $index_filename =~ s/\.pack/.idx/; $self->index_filename($index_filename); my $index_fh = IO::File->new($index_filename) || confess($!); $index_fh->binmode(); $index_fh->read( my $signature, 4 ); $index_fh->read( my $version, 4 ); $version = unpack( 'N', $version ); $index_fh->close; if ( $signature eq "\377tOc" ) { if ( $version == 2 ) { $self->index( Git::PurePerl::PackIndex::Version2->new( filename => $index_filename ) ); } else { confess("Unknown version"); } } else { $self->index( Git::PurePerl::PackIndex::Version1->new( filename => $index_filename ) ); } } sub get_object { my ( $self, $want_sha1 ) = @_; my $offset = $self->index->get_object_offset($want_sha1); return unless $offset; return $self->unpack_object($offset); } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/lib/Git/PurePerl/Pack/WithoutIndex.pm000644 000767 000024 00000006736 12767765163 023303 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Pack::WithoutIndex; use Moose; use MooseX::StrictConstructor; use namespace::autoclean; extends 'Git::PurePerl::Pack'; has 'offsets' => ( is => 'rw', isa => 'HashRef', required => 0 ); my @TYPES = ( 'none', 'commit', 'tree', 'blob', 'tag', '', 'ofs_delta', 'ref_delta' ); sub create_index { my ($self) = @_; my $index_filename = $self->filename; $index_filename =~ s/\.pack/.idx/; my $index_fh = IO::File->new("> $index_filename") || die $!; my $iod = IO::Digest->new( $index_fh, 'SHA' ); my $offsets = $self->create_index_offsets; my @fan_out_table; foreach my $sha1 ( sort keys %$offsets ) { my $offset = $offsets->{$sha1}; my $slot = unpack( 'C', pack( 'H*', $sha1 ) ); $fan_out_table[$slot]++; } foreach my $i ( 0 .. 255 ) { $index_fh->print( pack( 'N', $fan_out_table[$i] || 0 ) ) || die $!; $fan_out_table[ $i + 1 ] += $fan_out_table[$i] || 0; } foreach my $sha1 ( sort keys %$offsets ) { my $offset = $offsets->{$sha1}; $index_fh->print( pack( 'N', $offset ) ) || die $!; $index_fh->print( pack( 'H*', $sha1 ) ) || die $!; } # read the pack checksum from the end of the pack file my $size = -s $self->filename; my $fh = $self->fh; $fh->seek( $size - 20, 0 ) || die $!; my $read = $fh->read( my $pack_sha1, 20 ) || die $!; $index_fh->print($pack_sha1) || die $!; $index_fh->print( $iod->digest ) || die $!; $index_fh->close() || die $!; } sub create_index_offsets { my ($self) = @_; my $fh = $self->fh; $fh->read( my $signature, 4 ); $fh->read( my $version, 4 ); $version = unpack( 'N', $version ); $fh->read( my $objects, 4 ); $objects = unpack( 'N', $objects ); my %offsets; $self->offsets( \%offsets ); foreach my $i ( 1 .. $objects ) { my $offset = $fh->tell || die "Error telling filehandle: $!"; my $obj_offset = $offset; $fh->read( my $c, 1 ) || die "Error reading from pack: $!"; $c = unpack( 'C', $c ) || die $!; $offset++; my $size = ( $c & 0xf ); my $type_number = ( $c >> 4 ) & 7; my $type = $TYPES[$type_number] || confess "invalid type $type_number at offset $offset, size $size"; my $shift = 4; while ( ( $c & 0x80 ) != 0 ) { $fh->read( $c, 1 ) || die $!; $c = unpack( 'C', $c ) || die $!; $offset++; $size |= ( ( $c & 0x7f ) << $shift ); $shift += 7; } my $content; if ( $type eq 'ofs_delta' || $type eq 'ref_delta' ) { ( $type, $size, $content ) = $self->unpack_deltified( $type, $offset, $obj_offset, $size, \%offsets ); } elsif ( $type eq 'commit' || $type eq 'tree' || $type eq 'blob' || $type eq 'tag' ) { $content = $self->read_compressed( $offset, $size ); } else { confess "invalid type $type"; } my $raw = $type . ' ' . $size . "\0" . $content; my $sha1 = Digest::SHA->new; $sha1->add($raw); my $sha1_hex = $sha1->hexdigest; $offsets{$sha1_hex} = $obj_offset; } return \%offsets; } sub get_object { my ( $self, $want_sha1 ) = @_; my $offset = $self->offsets->{$want_sha1}; return unless $offset; return $self->unpack_object($offset); } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/lib/Git/PurePerl/Object/Blob.pm000644 000767 000024 00000000457 12767765163 022050 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Object::Blob; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use namespace::autoclean; extends 'Git::PurePerl::Object'; has 'kind' => ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'blob' ); __PACKAGE__->meta->make_immutable; 1; Git-PurePerl-0.53/lib/Git/PurePerl/Object/Commit.pm000644 000767 000024 00000005571 12767765163 022424 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Object::Commit; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use Encode qw/decode/; use namespace::autoclean; extends 'Git::PurePerl::Object'; has 'kind' => ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'commit' ); has 'tree_sha1' => ( is => 'rw', isa => 'Str', required => 0 ); has 'parent_sha1s' => ( is => 'rw', isa => 'ArrayRef[Str]', required => 0, default => sub { [] }); has 'author' => ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 0 ); has 'authored_time' => ( is => 'rw', isa => 'DateTime', required => 0 ); has 'committer' => ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 0 ); has 'committed_time' => ( is => 'rw', isa => 'DateTime', required => 0 ); has 'comment' => ( is => 'rw', isa => 'Str', required => 0 ); has 'encoding' => ( is => 'rw', isa => 'Str', required => 0 ); my %method_map = ( 'tree' => 'tree_sha1', 'parent' => '_push_parent_sha1', 'author' => 'authored_time', 'committer' => 'committed_time' ); sub BUILD { my $self = shift; return unless $self->content; my @lines = split "\n", $self->content; my %header; while ( my $line = shift @lines ) { last unless $line; my ( $key, $value ) = split ' ', $line, 2; push @{$header{$key}}, $value; } $header{encoding} ||= [ $self->git->config->get(key => "i18n.commitEncoding") || "utf-8" ]; my $encoding = $header{encoding}->[-1]; for my $key (keys %header) { for my $value (@{$header{$key}}) { $value = decode($encoding, $value); if ( $key eq 'committer' or $key eq 'author' ) { my @data = split ' ', $value; my ( $email, $epoch, $tz ) = splice( @data, -3 ); $email = substr( $email, 1, -1 ); my $name = join ' ', @data; my $actor = Git::PurePerl::Actor->new( name => $name, email => $email ); $self->$key($actor); $key = $method_map{$key}; my $dt = DateTime->from_epoch( epoch => $epoch, time_zone => $tz ); $self->$key($dt); } else { $key = $method_map{$key} || $key; $self->$key($value); } } } $self->comment( decode($encoding, join "\n", @lines) ); } sub tree { my $self = shift; return $self->git->get_object( $self->tree_sha1 ); } sub _push_parent_sha1 { my ($self, $sha1) = @_; push(@{$self->parent_sha1s}, $sha1); } sub parent_sha1 { return shift->parent_sha1s->[0]; } sub parent { my $self = shift; return $self->git->get_object( $self->parent_sha1 ); } sub parents { my $self = shift; return map { $self->git->get_object( $_ ) } @{$self->parent_sha1s}; } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/lib/Git/PurePerl/Object/Tag.pm000644 000767 000024 00000002743 12767765163 021705 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Object::Tag; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use namespace::autoclean; extends 'Git::PurePerl::Object'; has 'kind' => ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'tag' ); has 'object' => ( is => 'rw', isa => 'Str', required => 0 ); has 'tag' => ( is => 'rw', isa => 'Str', required => 0 ); has 'tagger' => ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 0 ); has 'tagged_time' => ( is => 'rw', isa => 'DateTime', required => 0 ); has 'comment' => ( is => 'rw', isa => 'Str', required => 0 ); has 'object_kind' => ( is => 'rw', isa => 'ObjectKind', required => 0); my %method_map = (type => 'object_kind'); sub BUILD { my $self = shift; my @lines = split "\n", $self->content; while ( my $line = shift @lines ) { last unless $line; my ( $key, $value ) = split ' ', $line, 2; if ($key eq 'tagger') { my @data = split ' ', $value; my ($email, $epoch, $tz) = splice(@data, -3); my $name = join(' ', @data); my $actor = Git::PurePerl::Actor->new( name => $name, email => $email ); $self->tagger($actor); my $dt= DateTime->from_epoch( epoch => $epoch, time_zone => $tz ); $self->tagged_time($dt); } else { my $method = $method_map{$key} || $key; $self->$method($value); } } $self->comment( join "\n", @lines ); } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/lib/Git/PurePerl/Object/Tree.pm000644 000767 000024 00000002464 12767765163 022071 0ustar00dbrookstaff000000 000000 package Git::PurePerl::Object::Tree; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use namespace::autoclean; extends 'Git::PurePerl::Object'; has 'kind' => ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'tree' ); has 'directory_entries' => ( is => 'rw', isa => 'ArrayRef[Git::PurePerl::DirectoryEntry]', required => 0, auto_deref => 1, ); sub BUILD { my $self = shift; my $content = $self->content; return unless $content; my @directory_entries; while ($content) { my $space_index = index( $content, ' ' ); my $mode = substr( $content, 0, $space_index ); $content = substr( $content, $space_index + 1 ); my $null_index = index( $content, "\0" ); my $filename = substr( $content, 0, $null_index ); $content = substr( $content, $null_index + 1 ); my $sha1 = unpack( 'H*', substr( $content, 0, 20 ) ); $content = substr( $content, 20 ); push @directory_entries, Git::PurePerl::DirectoryEntry->new( mode => $mode, filename => $filename, sha1 => $sha1, git => $self->git, ); } $self->directory_entries( \@directory_entries ); } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/lib/Git/PurePerl/NewObject/Blob.pm000644 000767 000024 00000000465 12767765163 022521 0ustar00dbrookstaff000000 000000 package Git::PurePerl::NewObject::Blob; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use namespace::autoclean; extends 'Git::PurePerl::NewObject'; has 'kind' => ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'blob' ); __PACKAGE__->meta->make_immutable; 1; Git-PurePerl-0.53/lib/Git/PurePerl/NewObject/Commit.pm000644 000767 000024 00000003445 12767765163 023074 0ustar00dbrookstaff000000 000000 package Git::PurePerl::NewObject::Commit; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use DateTime; use namespace::autoclean; extends 'Git::PurePerl::NewObject'; has 'kind' => ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'commit' ); has 'tree' => ( is => 'rw', isa => 'Str', required => 1 ); has 'parent' => ( is => 'rw', isa => 'Str|ArrayRef[Str]', required => 0 ); has 'author' => ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 1 ); has 'authored_time' => ( is => 'rw', isa => 'DateTime', required => 1 ); has 'committer' => ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 1 ); has 'committed_time' => ( is => 'rw', isa => 'DateTime', required => 1 ); has 'comment' => ( is => 'rw', isa => 'Str', required => 1 ); sub _build_content { my $self = shift; my $content; $content .= 'tree ' . $self->tree . "\n"; if ( my $parent = $self->parent ) { if ( ref $parent ) { $content .= "parent $_\n" for @$parent; } else { $content .= "parent $parent\n"; } } $content .= "author " . $self->author->name . ' <' . $self->author->email . "> " . $self->authored_time->epoch . " " . DateTime::TimeZone->offset_as_string( $self->authored_time->offset ) . "\n"; $content .= "committer " . $self->committer->name . ' <' . $self->author->email . "> " . $self->committed_time->epoch . " " . DateTime::TimeZone->offset_as_string( $self->committed_time->offset ) . "\n"; $content .= "\n"; my $comment = $self->comment; chomp $comment; $content .= "$comment\n"; $self->content($content); } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/lib/Git/PurePerl/NewObject/Tag.pm000644 000767 000024 00000001053 12767765163 022350 0ustar00dbrookstaff000000 000000 package Git::PurePerl::NewObject::Tag; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use namespace::autoclean; extends 'Git::PurePerl::NewObject'; has 'kind' => ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'tag' ); has 'object' => ( is => 'rw', isa => 'Str', required => 1 ); has 'tag' => ( is => 'rw', isa => 'Str', required => 1 ); has 'tagger' => ( is => 'rw', isa => 'Str', required => 1 ); has 'comment' => ( is => 'rw', isa => 'Str', required => 1 ); __PACKAGE__->meta->make_immutable; 1; Git-PurePerl-0.53/lib/Git/PurePerl/NewObject/Tree.pm000644 000767 000024 00000001343 12767765163 022536 0ustar00dbrookstaff000000 000000 package Git::PurePerl::NewObject::Tree; use Moose; use MooseX::StrictConstructor; use Moose::Util::TypeConstraints; use namespace::autoclean; extends 'Git::PurePerl::NewObject'; has 'kind' => ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'tree' ); has 'directory_entries' => ( is => 'rw', isa => 'ArrayRef[Git::PurePerl::NewDirectoryEntry]', required => 1, auto_deref => 1, ); sub _build_content { my $self = shift; my $content; foreach my $de ( $self->directory_entries ) { $content .= $de->mode . ' ' . $de->filename . "\0" . pack( 'H*', $de->sha1 ); } $self->content($content); } __PACKAGE__->meta->make_immutable; Git-PurePerl-0.53/inc/Module/000755 000767 000024 00000000000 12770006122 016340 5ustar00dbrookstaff000000 000000 Git-PurePerl-0.53/inc/Module/Install/000755 000767 000024 00000000000 12770006122 017746 5ustar00dbrookstaff000000 000000 Git-PurePerl-0.53/inc/Module/Install.pm000644 000767 000024 00000030217 12770000242 020304 0ustar00dbrookstaff000000 000000 #line 1 package Module::Install; # For any maintainers: # The load order for Module::Install is a bit magic. # It goes something like this... # # IF ( host has Module::Install installed, creating author mode ) { # 1. Makefile.PL calls "use inc::Module::Install" # 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install # 3. The installed version of inc::Module::Install loads # 4. inc::Module::Install calls "require Module::Install" # 5. The ./inc/ version of Module::Install loads # } ELSE { # 1. Makefile.PL calls "use inc::Module::Install" # 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install # 3. The ./inc/ version of Module::Install loads # } use 5.006; use strict 'vars'; use Cwd (); use File::Find (); use File::Path (); use vars qw{$VERSION $MAIN}; BEGIN { # All Module::Install core packages now require synchronised versions. # This will be used to ensure we don't accidentally load old or # different versions of modules. # This is not enforced yet, but will be some time in the next few # releases once we can make sure it won't clash with custom # Module::Install extensions. $VERSION = '1.16'; # Storage for the pseudo-singleton $MAIN = undef; *inc::Module::Install::VERSION = *VERSION; @inc::Module::Install::ISA = __PACKAGE__; } sub import { my $class = shift; my $self = $class->new(@_); my $who = $self->_caller; #------------------------------------------------------------- # all of the following checks should be included in import(), # to allow "eval 'require Module::Install; 1' to test # installation of Module::Install. (RT #51267) #------------------------------------------------------------- # Whether or not inc::Module::Install is actually loaded, the # $INC{inc/Module/Install.pm} is what will still get set as long as # the caller loaded module this in the documented manner. # If not set, the caller may NOT have loaded the bundled version, and thus # they may not have a MI version that works with the Makefile.PL. This would # result in false errors or unexpected behaviour. And we don't want that. my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm'; unless ( $INC{$file} ) { die <<"END_DIE" } Please invoke ${\__PACKAGE__} with: use inc::${\__PACKAGE__}; not: use ${\__PACKAGE__}; END_DIE # This reportedly fixes a rare Win32 UTC file time issue, but # as this is a non-cross-platform XS module not in the core, # we shouldn't really depend on it. See RT #24194 for detail. # (Also, this module only supports Perl 5.6 and above). eval "use Win32::UTCFileTime" if $^O eq 'MSWin32' && $] >= 5.006; # If the script that is loading Module::Install is from the future, # then make will detect this and cause it to re-run over and over # again. This is bad. Rather than taking action to touch it (which # is unreliable on some platforms and requires write permissions) # for now we should catch this and refuse to run. if ( -f $0 ) { my $s = (stat($0))[9]; # If the modification time is only slightly in the future, # sleep briefly to remove the problem. my $a = $s - time; if ( $a > 0 and $a < 5 ) { sleep 5 } # Too far in the future, throw an error. my $t = time; if ( $s > $t ) { die <<"END_DIE" } Your installer $0 has a modification time in the future ($s > $t). This is known to create infinite loops in make. Please correct this, then run $0 again. END_DIE } # Build.PL was formerly supported, but no longer is due to excessive # difficulty in implementing every single feature twice. if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" } Module::Install no longer supports Build.PL. It was impossible to maintain duel backends, and has been deprecated. Please remove all Build.PL files and only use the Makefile.PL installer. END_DIE #------------------------------------------------------------- # To save some more typing in Module::Install installers, every... # use inc::Module::Install # ...also acts as an implicit use strict. $^H |= strict::bits(qw(refs subs vars)); #------------------------------------------------------------- unless ( -f $self->{file} ) { foreach my $key (keys %INC) { delete $INC{$key} if $key =~ /Module\/Install/; } local $^W; require "$self->{path}/$self->{dispatch}.pm"; File::Path::mkpath("$self->{prefix}/$self->{author}"); $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self ); $self->{admin}->init; @_ = ($class, _self => $self); goto &{"$self->{name}::import"}; } local $^W; *{"${who}::AUTOLOAD"} = $self->autoload; $self->preload; # Unregister loader and worker packages so subdirs can use them again delete $INC{'inc/Module/Install.pm'}; delete $INC{'Module/Install.pm'}; # Save to the singleton $MAIN = $self; return 1; } sub autoload { my $self = shift; my $who = $self->_caller; my $cwd = Cwd::getcwd(); my $sym = "${who}::AUTOLOAD"; $sym->{$cwd} = sub { my $pwd = Cwd::getcwd(); if ( my $code = $sym->{$pwd} ) { # Delegate back to parent dirs goto &$code unless $cwd eq $pwd; } unless ($$sym =~ s/([^:]+)$//) { # XXX: it looks like we can't retrieve the missing function # via $$sym (usually $main::AUTOLOAD) in this case. # I'm still wondering if we should slurp Makefile.PL to # get some context or not ... my ($package, $file, $line) = caller; die <<"EOT"; Unknown function is found at $file line $line. Execution of $file aborted due to runtime errors. If you're a contributor to a project, you may need to install some Module::Install extensions from CPAN (or other repository). If you're a user of a module, please contact the author. EOT } my $method = $1; if ( uc($method) eq $method ) { # Do nothing return; } elsif ( $method =~ /^_/ and $self->can($method) ) { # Dispatch to the root M:I class return $self->$method(@_); } # Dispatch to the appropriate plugin unshift @_, ( $self, $1 ); goto &{$self->can('call')}; }; } sub preload { my $self = shift; unless ( $self->{extensions} ) { $self->load_extensions( "$self->{prefix}/$self->{path}", $self ); } my @exts = @{$self->{extensions}}; unless ( @exts ) { @exts = $self->{admin}->load_all_extensions; } my %seen; foreach my $obj ( @exts ) { while (my ($method, $glob) = each %{ref($obj) . '::'}) { next unless $obj->can($method); next if $method =~ /^_/; next if $method eq uc($method); $seen{$method}++; } } my $who = $self->_caller; foreach my $name ( sort keys %seen ) { local $^W; *{"${who}::$name"} = sub { ${"${who}::AUTOLOAD"} = "${who}::$name"; goto &{"${who}::AUTOLOAD"}; }; } } sub new { my ($class, %args) = @_; delete $INC{'FindBin.pm'}; { # to suppress the redefine warning local $SIG{__WARN__} = sub {}; require FindBin; } # ignore the prefix on extension modules built from top level. my $base_path = Cwd::abs_path($FindBin::Bin); unless ( Cwd::abs_path(Cwd::getcwd()) eq $base_path ) { delete $args{prefix}; } return $args{_self} if $args{_self}; $args{dispatch} ||= 'Admin'; $args{prefix} ||= 'inc'; $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author'); $args{bundle} ||= 'inc/BUNDLES'; $args{base} ||= $base_path; $class =~ s/^\Q$args{prefix}\E:://; $args{name} ||= $class; $args{version} ||= $class->VERSION; unless ( $args{path} ) { $args{path} = $args{name}; $args{path} =~ s!::!/!g; } $args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm"; $args{wrote} = 0; bless( \%args, $class ); } sub call { my ($self, $method) = @_; my $obj = $self->load($method) or return; splice(@_, 0, 2, $obj); goto &{$obj->can($method)}; } sub load { my ($self, $method) = @_; $self->load_extensions( "$self->{prefix}/$self->{path}", $self ) unless $self->{extensions}; foreach my $obj (@{$self->{extensions}}) { return $obj if $obj->can($method); } my $admin = $self->{admin} or die <<"END_DIE"; The '$method' method does not exist in the '$self->{prefix}' path! Please remove the '$self->{prefix}' directory and run $0 again to load it. END_DIE my $obj = $admin->load($method, 1); push @{$self->{extensions}}, $obj; $obj; } sub load_extensions { my ($self, $path, $top) = @_; my $should_reload = 0; unless ( grep { ! ref $_ and lc $_ eq lc $self->{prefix} } @INC ) { unshift @INC, $self->{prefix}; $should_reload = 1; } foreach my $rv ( $self->find_extensions($path) ) { my ($file, $pkg) = @{$rv}; next if $self->{pathnames}{$pkg}; local $@; my $new = eval { local $^W; require $file; $pkg->can('new') }; unless ( $new ) { warn $@ if $@; next; } $self->{pathnames}{$pkg} = $should_reload ? delete $INC{$file} : $INC{$file}; push @{$self->{extensions}}, &{$new}($pkg, _top => $top ); } $self->{extensions} ||= []; } sub find_extensions { my ($self, $path) = @_; my @found; File::Find::find( sub { my $file = $File::Find::name; return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is; my $subpath = $1; return if lc($subpath) eq lc($self->{dispatch}); $file = "$self->{path}/$subpath.pm"; my $pkg = "$self->{name}::$subpath"; $pkg =~ s!/!::!g; # If we have a mixed-case package name, assume case has been preserved # correctly. Otherwise, root through the file to locate the case-preserved # version of the package name. if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) { my $content = Module::Install::_read($subpath . '.pm'); my $in_pod = 0; foreach ( split /\n/, $content ) { $in_pod = 1 if /^=\w/; $in_pod = 0 if /^=cut/; next if ($in_pod || /^=cut/); # skip pod text next if /^\s*#/; # and comments if ( m/^\s*package\s+($pkg)\s*;/i ) { $pkg = $1; last; } } } push @found, [ $file, $pkg ]; }, $path ) if -d $path; @found; } ##################################################################### # Common Utility Functions sub _caller { my $depth = 0; my $call = caller($depth); while ( $call eq __PACKAGE__ ) { $depth++; $call = caller($depth); } return $call; } # Done in evals to avoid confusing Perl::MinimumVersion eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; sub _read { local *FH; open( FH, '<', $_[0] ) or die "open($_[0]): $!"; binmode FH; my $string = do { local $/; }; close FH or die "close($_[0]): $!"; return $string; } END_NEW sub _read { local *FH; open( FH, "< $_[0]" ) or die "open($_[0]): $!"; binmode FH; my $string = do { local $/; }; close FH or die "close($_[0]): $!"; return $string; } END_OLD sub _readperl { my $string = Module::Install::_read($_[0]); $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; $string =~ s/(\n)\n*__(?:DATA|END)__\b.*\z/$1/s; $string =~ s/\n\n=\w+.+?\n\n=cut\b.+?\n+/\n\n/sg; return $string; } sub _readpod { my $string = Module::Install::_read($_[0]); $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; return $string if $_[0] =~ /\.pod\z/; $string =~ s/(^|\n=cut\b.+?\n+)[^=\s].+?\n(\n=\w+|\z)/$1$2/sg; $string =~ s/\n*=pod\b[^\n]*\n+/\n\n/sg; $string =~ s/\n*=cut\b[^\n]*\n+/\n\n/sg; $string =~ s/^\n+//s; return $string; } # Done in evals to avoid confusing Perl::MinimumVersion eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; sub _write { local *FH; open( FH, '>', $_[0] ) or die "open($_[0]): $!"; binmode FH; foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!"; } close FH or die "close($_[0]): $!"; } END_NEW sub _write { local *FH; open( FH, "> $_[0]" ) or die "open($_[0]): $!"; binmode FH; foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!"; } close FH or die "close($_[0]): $!"; } END_OLD # _version is for processing module versions (eg, 1.03_05) not # Perl versions (eg, 5.8.1). sub _version { my $s = shift || 0; my $d =()= $s =~ /(\.)/g; if ( $d >= 2 ) { # Normalise multipart versions $s =~ s/(\.)(\d{1,3})/sprintf("$1%03d",$2)/eg; } $s =~ s/^(\d+)\.?//; my $l = $1 || 0; my @v = map { $_ . '0' x (3 - length $_) } $s =~ /(\d{1,3})\D?/g; $l = $l . '.' . join '', @v if @v; return $l + 0; } sub _cmp { _version($_[1]) <=> _version($_[2]); } # Cloned from Params::Util::_CLASS sub _CLASS { ( defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s ) ? $_[0] : undef; } 1; # Copyright 2008 - 2012 Adam Kennedy. Git-PurePerl-0.53/inc/Module/Install/Base.pm000644 000767 000024 00000002147 12770000242 021157 0ustar00dbrookstaff000000 000000 #line 1 package Module::Install::Base; use strict 'vars'; use vars qw{$VERSION}; BEGIN { $VERSION = '1.16'; } # Suspend handler for "redefined" warnings BEGIN { my $w = $SIG{__WARN__}; $SIG{__WARN__} = sub { $w }; } #line 42 sub new { my $class = shift; unless ( defined &{"${class}::call"} ) { *{"${class}::call"} = sub { shift->_top->call(@_) }; } unless ( defined &{"${class}::load"} ) { *{"${class}::load"} = sub { shift->_top->load(@_) }; } bless { @_ }, $class; } #line 61 sub AUTOLOAD { local $@; my $func = eval { shift->_top->autoload } or return; goto &$func; } #line 75 sub _top { $_[0]->{_top}; } #line 90 sub admin { $_[0]->_top->{admin} or Module::Install::Base::FakeAdmin->new; } #line 106 sub is_admin { ! $_[0]->admin->isa('Module::Install::Base::FakeAdmin'); } sub DESTROY {} package Module::Install::Base::FakeAdmin; use vars qw{$VERSION}; BEGIN { $VERSION = $Module::Install::Base::VERSION; } my $fake; sub new { $fake ||= bless(\@_, $_[0]); } sub AUTOLOAD {} sub DESTROY {} # Restore warning handler BEGIN { $SIG{__WARN__} = $SIG{__WARN__}->(); } 1; #line 159 Git-PurePerl-0.53/inc/Module/Install/Can.pm000644 000767 000024 00000006157 12770000242 021013 0ustar00dbrookstaff000000 000000 #line 1 package Module::Install::Can; use strict; use Config (); use ExtUtils::MakeMaker (); use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.16'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } # check if we can load some module ### Upgrade this to not have to load the module if possible sub can_use { my ($self, $mod, $ver) = @_; $mod =~ s{::|\\}{/}g; $mod .= '.pm' unless $mod =~ /\.pm$/i; my $pkg = $mod; $pkg =~ s{/}{::}g; $pkg =~ s{\.pm$}{}i; local $@; eval { require $mod; $pkg->VERSION($ver || 0); 1 }; } # Check if we can run some command sub can_run { my ($self, $cmd) = @_; my $_cmd = $cmd; return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { next if $dir eq ''; require File::Spec; my $abs = File::Spec->catfile($dir, $cmd); return $abs if (-x $abs or $abs = MM->maybe_command($abs)); } return; } # Can our C compiler environment build XS files sub can_xs { my $self = shift; # Ensure we have the CBuilder module $self->configure_requires( 'ExtUtils::CBuilder' => 0.27 ); # Do we have the configure_requires checker? local $@; eval "require ExtUtils::CBuilder;"; if ( $@ ) { # They don't obey configure_requires, so it is # someone old and delicate. Try to avoid hurting # them by falling back to an older simpler test. return $self->can_cc(); } # Do we have a working C compiler my $builder = ExtUtils::CBuilder->new( quiet => 1, ); unless ( $builder->have_compiler ) { # No working C compiler return 0; } # Write a C file representative of what XS becomes require File::Temp; my ( $FH, $tmpfile ) = File::Temp::tempfile( "compilexs-XXXXX", SUFFIX => '.c', ); binmode $FH; print $FH <<'END_C'; #include "EXTERN.h" #include "perl.h" #include "XSUB.h" int main(int argc, char **argv) { return 0; } int boot_sanexs() { return 1; } END_C close $FH; # Can the C compiler access the same headers XS does my @libs = (); my $object = undef; eval { local $^W = 0; $object = $builder->compile( source => $tmpfile, ); @libs = $builder->link( objects => $object, module_name => 'sanexs', ); }; my $result = $@ ? 0 : 1; # Clean up all the build files foreach ( $tmpfile, $object, @libs ) { next unless defined $_; 1 while unlink; } return $result; } # Can we locate a (the) C compiler sub can_cc { my $self = shift; my @chunks = split(/ /, $Config::Config{cc}) or return; # $Config{cc} may contain args; try to find out the program part while (@chunks) { return $self->can_run("@chunks") || (pop(@chunks), next); } return; } # Fix Cygwin bug on maybe_command(); if ( $^O eq 'cygwin' ) { require ExtUtils::MM_Cygwin; require ExtUtils::MM_Win32; if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) { *ExtUtils::MM_Cygwin::maybe_command = sub { my ($self, $file) = @_; if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) { ExtUtils::MM_Win32->maybe_command($file); } else { ExtUtils::MM_Unix->maybe_command($file); } } } } 1; __END__ #line 236 Git-PurePerl-0.53/inc/Module/Install/Fetch.pm000644 000767 000024 00000004627 12770000242 021343 0ustar00dbrookstaff000000 000000 #line 1 package Module::Install::Fetch; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.16'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub get_file { my ($self, %args) = @_; my ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) { $args{url} = $args{ftp_url} or (warn("LWP support unavailable!\n"), return); ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; } $|++; print "Fetching '$file' from $host... "; unless (eval { require Socket; Socket::inet_aton($host) }) { warn "'$host' resolve failed!\n"; return; } return unless $scheme eq 'ftp' or $scheme eq 'http'; require Cwd; my $dir = Cwd::getcwd(); chdir $args{local_dir} or return if exists $args{local_dir}; if (eval { require LWP::Simple; 1 }) { LWP::Simple::mirror($args{url}, $file); } elsif (eval { require Net::FTP; 1 }) { eval { # use Net::FTP to get past firewall my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600); $ftp->login("anonymous", 'anonymous@example.com'); $ftp->cwd($path); $ftp->binary; $ftp->get($file) or (warn("$!\n"), return); $ftp->quit; } } elsif (my $ftp = $self->can_run('ftp')) { eval { # no Net::FTP, fallback to ftp.exe require FileHandle; my $fh = FileHandle->new; local $SIG{CHLD} = 'IGNORE'; unless ($fh->open("|$ftp -n")) { warn "Couldn't open ftp: $!\n"; chdir $dir; return; } my @dialog = split(/\n/, <<"END_FTP"); open $host user anonymous anonymous\@example.com cd $path binary get $file $file quit END_FTP foreach (@dialog) { $fh->print("$_\n") } $fh->close; } } else { warn "No working 'ftp' program available!\n"; chdir $dir; return; } unless (-f $file) { warn "Fetching failed: $@\n"; chdir $dir; return; } return if exists $args{size} and -s $file != $args{size}; system($args{run}) if exists $args{run}; unlink($file) if $args{remove}; print(((!exists $args{check_for} or -e $args{check_for}) ? "done!" : "failed! ($!)"), "\n"); chdir $dir; return !$?; } 1; Git-PurePerl-0.53/inc/Module/Install/Makefile.pm000644 000767 000024 00000027437 12770000242 022033 0ustar00dbrookstaff000000 000000 #line 1 package Module::Install::Makefile; use strict 'vars'; use ExtUtils::MakeMaker (); use Module::Install::Base (); use Fcntl qw/:flock :seek/; use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.16'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub Makefile { $_[0] } my %seen = (); sub prompt { shift; # Infinite loop protection my @c = caller(); if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) { die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])"; } # In automated testing or non-interactive session, always use defaults if ( ($ENV{AUTOMATED_TESTING} or -! -t STDIN) and ! $ENV{PERL_MM_USE_DEFAULT} ) { local $ENV{PERL_MM_USE_DEFAULT} = 1; goto &ExtUtils::MakeMaker::prompt; } else { goto &ExtUtils::MakeMaker::prompt; } } # Store a cleaned up version of the MakeMaker version, # since we need to behave differently in a variety of # ways based on the MM version. my $makemaker = eval $ExtUtils::MakeMaker::VERSION; # If we are passed a param, do a "newer than" comparison. # Otherwise, just return the MakeMaker version. sub makemaker { ( @_ < 2 or $makemaker >= eval($_[1]) ) ? $makemaker : 0 } # Ripped from ExtUtils::MakeMaker 6.56, and slightly modified # as we only need to know here whether the attribute is an array # or a hash or something else (which may or may not be appendable). my %makemaker_argtype = ( C => 'ARRAY', CONFIG => 'ARRAY', # CONFIGURE => 'CODE', # ignore DIR => 'ARRAY', DL_FUNCS => 'HASH', DL_VARS => 'ARRAY', EXCLUDE_EXT => 'ARRAY', EXE_FILES => 'ARRAY', FUNCLIST => 'ARRAY', H => 'ARRAY', IMPORTS => 'HASH', INCLUDE_EXT => 'ARRAY', LIBS => 'ARRAY', # ignore '' MAN1PODS => 'HASH', MAN3PODS => 'HASH', META_ADD => 'HASH', META_MERGE => 'HASH', PL_FILES => 'HASH', PM => 'HASH', PMLIBDIRS => 'ARRAY', PMLIBPARENTDIRS => 'ARRAY', PREREQ_PM => 'HASH', CONFIGURE_REQUIRES => 'HASH', SKIP => 'ARRAY', TYPEMAPS => 'ARRAY', XS => 'HASH', # VERSION => ['version',''], # ignore # _KEEP_AFTER_FLUSH => '', clean => 'HASH', depend => 'HASH', dist => 'HASH', dynamic_lib=> 'HASH', linkext => 'HASH', macro => 'HASH', postamble => 'HASH', realclean => 'HASH', test => 'HASH', tool_autosplit => 'HASH', # special cases where you can use makemaker_append CCFLAGS => 'APPENDABLE', DEFINE => 'APPENDABLE', INC => 'APPENDABLE', LDDLFLAGS => 'APPENDABLE', LDFROM => 'APPENDABLE', ); sub makemaker_args { my ($self, %new_args) = @_; my $args = ( $self->{makemaker_args} ||= {} ); foreach my $key (keys %new_args) { if ($makemaker_argtype{$key}) { if ($makemaker_argtype{$key} eq 'ARRAY') { $args->{$key} = [] unless defined $args->{$key}; unless (ref $args->{$key} eq 'ARRAY') { $args->{$key} = [$args->{$key}] } push @{$args->{$key}}, ref $new_args{$key} eq 'ARRAY' ? @{$new_args{$key}} : $new_args{$key}; } elsif ($makemaker_argtype{$key} eq 'HASH') { $args->{$key} = {} unless defined $args->{$key}; foreach my $skey (keys %{ $new_args{$key} }) { $args->{$key}{$skey} = $new_args{$key}{$skey}; } } elsif ($makemaker_argtype{$key} eq 'APPENDABLE') { $self->makemaker_append($key => $new_args{$key}); } } else { if (defined $args->{$key}) { warn qq{MakeMaker attribute "$key" is overriden; use "makemaker_append" to append values\n}; } $args->{$key} = $new_args{$key}; } } return $args; } # For mm args that take multiple space-separated args, # append an argument to the current list. sub makemaker_append { my $self = shift; my $name = shift; my $args = $self->makemaker_args; $args->{$name} = defined $args->{$name} ? join( ' ', $args->{$name}, @_ ) : join( ' ', @_ ); } sub build_subdirs { my $self = shift; my $subdirs = $self->makemaker_args->{DIR} ||= []; for my $subdir (@_) { push @$subdirs, $subdir; } } sub clean_files { my $self = shift; my $clean = $self->makemaker_args->{clean} ||= {}; %$clean = ( %$clean, FILES => join ' ', grep { length $_ } ($clean->{FILES} || (), @_), ); } sub realclean_files { my $self = shift; my $realclean = $self->makemaker_args->{realclean} ||= {}; %$realclean = ( %$realclean, FILES => join ' ', grep { length $_ } ($realclean->{FILES} || (), @_), ); } sub libs { my $self = shift; my $libs = ref $_[0] ? shift : [ shift ]; $self->makemaker_args( LIBS => $libs ); } sub inc { my $self = shift; $self->makemaker_args( INC => shift ); } sub _wanted_t { } sub tests_recursive { my $self = shift; my $dir = shift || 't'; unless ( -d $dir ) { die "tests_recursive dir '$dir' does not exist"; } my %tests = map { $_ => 1 } split / /, ($self->tests || ''); require File::Find; File::Find::find( sub { /\.t$/ and -f $_ and $tests{"$File::Find::dir/*.t"} = 1 }, $dir ); $self->tests( join ' ', sort keys %tests ); } sub write { my $self = shift; die "&Makefile->write() takes no arguments\n" if @_; # Check the current Perl version my $perl_version = $self->perl_version; if ( $perl_version ) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version"; } # Make sure we have a new enough MakeMaker require ExtUtils::MakeMaker; if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) { # This previous attempted to inherit the version of # ExtUtils::MakeMaker in use by the module author, but this # was found to be untenable as some authors build releases # using future dev versions of EU:MM that nobody else has. # Instead, #toolchain suggests we use 6.59 which is the most # stable version on CPAN at time of writing and is, to quote # ribasushi, "not terminally fucked, > and tested enough". # TODO: We will now need to maintain this over time to push # the version up as new versions are released. $self->build_requires( 'ExtUtils::MakeMaker' => 6.59 ); $self->configure_requires( 'ExtUtils::MakeMaker' => 6.59 ); } else { # Allow legacy-compatibility with 5.005 by depending on the # most recent EU:MM that supported 5.005. $self->build_requires( 'ExtUtils::MakeMaker' => 6.36 ); $self->configure_requires( 'ExtUtils::MakeMaker' => 6.36 ); } # Generate the MakeMaker params my $args = $self->makemaker_args; $args->{DISTNAME} = $self->name; $args->{NAME} = $self->module_name || $self->name; $args->{NAME} =~ s/-/::/g; $args->{VERSION} = $self->version or die <<'EOT'; ERROR: Can't determine distribution version. Please specify it explicitly via 'version' in Makefile.PL, or set a valid $VERSION in a module, and provide its file path via 'version_from' (or 'all_from' if you prefer) in Makefile.PL. EOT if ( $self->tests ) { my @tests = split ' ', $self->tests; my %seen; $args->{test} = { TESTS => (join ' ', grep {!$seen{$_}++} @tests), }; } elsif ( $Module::Install::ExtraTests::use_extratests ) { # Module::Install::ExtraTests doesn't set $self->tests and does its own tests via harness. # So, just ignore our xt tests here. } elsif ( -d 'xt' and ($Module::Install::AUTHOR or $ENV{RELEASE_TESTING}) ) { $args->{test} = { TESTS => join( ' ', map { "$_/*.t" } grep { -d $_ } qw{ t xt } ), }; } if ( $] >= 5.005 ) { $args->{ABSTRACT} = $self->abstract; $args->{AUTHOR} = join ', ', @{$self->author || []}; } if ( $self->makemaker(6.10) ) { $args->{NO_META} = 1; #$args->{NO_MYMETA} = 1; } if ( $self->makemaker(6.17) and $self->sign ) { $args->{SIGN} = 1; } unless ( $self->is_admin ) { delete $args->{SIGN}; } if ( $self->makemaker(6.31) and $self->license ) { $args->{LICENSE} = $self->license; } my $prereq = ($args->{PREREQ_PM} ||= {}); %$prereq = ( %$prereq, map { @$_ } # flatten [module => version] map { @$_ } grep $_, ($self->requires) ); # Remove any reference to perl, PREREQ_PM doesn't support it delete $args->{PREREQ_PM}->{perl}; # Merge both kinds of requires into BUILD_REQUIRES my $build_prereq = ($args->{BUILD_REQUIRES} ||= {}); %$build_prereq = ( %$build_prereq, map { @$_ } # flatten [module => version] map { @$_ } grep $_, ($self->configure_requires, $self->build_requires) ); # Remove any reference to perl, BUILD_REQUIRES doesn't support it delete $args->{BUILD_REQUIRES}->{perl}; # Delete bundled dists from prereq_pm, add it to Makefile DIR my $subdirs = ($args->{DIR} || []); if ($self->bundles) { my %processed; foreach my $bundle (@{ $self->bundles }) { my ($mod_name, $dist_dir) = @$bundle; delete $prereq->{$mod_name}; $dist_dir = File::Basename::basename($dist_dir); # dir for building this module if (not exists $processed{$dist_dir}) { if (-d $dist_dir) { # List as sub-directory to be processed by make push @$subdirs, $dist_dir; } # Else do nothing: the module is already present on the system $processed{$dist_dir} = undef; } } } unless ( $self->makemaker('6.55_03') ) { %$prereq = (%$prereq,%$build_prereq); delete $args->{BUILD_REQUIRES}; } if ( my $perl_version = $self->perl_version ) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version"; if ( $self->makemaker(6.48) ) { $args->{MIN_PERL_VERSION} = $perl_version; } } if ($self->installdirs) { warn qq{old INSTALLDIRS (probably set by makemaker_args) is overriden by installdirs\n} if $args->{INSTALLDIRS}; $args->{INSTALLDIRS} = $self->installdirs; } my %args = map { ( $_ => $args->{$_} ) } grep {defined($args->{$_} ) } keys %$args; my $user_preop = delete $args{dist}->{PREOP}; if ( my $preop = $self->admin->preop($user_preop) ) { foreach my $key ( keys %$preop ) { $args{dist}->{$key} = $preop->{$key}; } } my $mm = ExtUtils::MakeMaker::WriteMakefile(%args); $self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile'); } sub fix_up_makefile { my $self = shift; my $makefile_name = shift; my $top_class = ref($self->_top) || ''; my $top_version = $self->_top->VERSION || ''; my $preamble = $self->preamble ? "# Preamble by $top_class $top_version\n" . $self->preamble : ''; my $postamble = "# Postamble by $top_class $top_version\n" . ($self->postamble || ''); local *MAKEFILE; open MAKEFILE, "+< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!"; eval { flock MAKEFILE, LOCK_EX }; my $makefile = do { local $/; }; $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /; $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g; $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g; $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m; $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m; # Module::Install will never be used to build the Core Perl # Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks # PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist $makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m; #$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m; # Perl 5.005 mentions PERL_LIB explicitly, so we have to remove that as well. $makefile =~ s/(\"?)-I\$\(PERL_LIB\)\1//g; # XXX - This is currently unused; not sure if it breaks other MM-users # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg; seek MAKEFILE, 0, SEEK_SET; truncate MAKEFILE, 0; print MAKEFILE "$preamble$makefile$postamble" or die $!; close MAKEFILE or die $!; 1; } sub preamble { my ($self, $text) = @_; $self->{preamble} = $text . $self->{preamble} if defined $text; $self->{preamble}; } sub postamble { my ($self, $text) = @_; $self->{postamble} ||= $self->admin->postamble; $self->{postamble} .= $text if defined $text; $self->{postamble} } 1; __END__ #line 544 Git-PurePerl-0.53/inc/Module/Install/Metadata.pm000644 000767 000024 00000043302 12770000242 022023 0ustar00dbrookstaff000000 000000 #line 1 package Module::Install::Metadata; use strict 'vars'; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.16'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } my @boolean_keys = qw{ sign }; my @scalar_keys = qw{ name module_name abstract version distribution_type tests installdirs }; my @tuple_keys = qw{ configure_requires build_requires requires recommends bundles resources }; my @resource_keys = qw{ homepage bugtracker repository }; my @array_keys = qw{ keywords author }; *authors = \&author; sub Meta { shift } sub Meta_BooleanKeys { @boolean_keys } sub Meta_ScalarKeys { @scalar_keys } sub Meta_TupleKeys { @tuple_keys } sub Meta_ResourceKeys { @resource_keys } sub Meta_ArrayKeys { @array_keys } foreach my $key ( @boolean_keys ) { *$key = sub { my $self = shift; if ( defined wantarray and not @_ ) { return $self->{values}->{$key}; } $self->{values}->{$key} = ( @_ ? $_[0] : 1 ); return $self; }; } foreach my $key ( @scalar_keys ) { *$key = sub { my $self = shift; return $self->{values}->{$key} if defined wantarray and !@_; $self->{values}->{$key} = shift; return $self; }; } foreach my $key ( @array_keys ) { *$key = sub { my $self = shift; return $self->{values}->{$key} if defined wantarray and !@_; $self->{values}->{$key} ||= []; push @{$self->{values}->{$key}}, @_; return $self; }; } foreach my $key ( @resource_keys ) { *$key = sub { my $self = shift; unless ( @_ ) { return () unless $self->{values}->{resources}; return map { $_->[1] } grep { $_->[0] eq $key } @{ $self->{values}->{resources} }; } return $self->{values}->{resources}->{$key} unless @_; my $uri = shift or die( "Did not provide a value to $key()" ); $self->resources( $key => $uri ); return 1; }; } foreach my $key ( grep { $_ ne "resources" } @tuple_keys) { *$key = sub { my $self = shift; return $self->{values}->{$key} unless @_; my @added; while ( @_ ) { my $module = shift or last; my $version = shift || 0; push @added, [ $module, $version ]; } push @{ $self->{values}->{$key} }, @added; return map {@$_} @added; }; } # Resource handling my %lc_resource = map { $_ => 1 } qw{ homepage license bugtracker repository }; sub resources { my $self = shift; while ( @_ ) { my $name = shift or last; my $value = shift or next; if ( $name eq lc $name and ! $lc_resource{$name} ) { die("Unsupported reserved lowercase resource '$name'"); } $self->{values}->{resources} ||= []; push @{ $self->{values}->{resources} }, [ $name, $value ]; } $self->{values}->{resources}; } # Aliases for build_requires that will have alternative # meanings in some future version of META.yml. sub test_requires { shift->build_requires(@_) } sub install_requires { shift->build_requires(@_) } # Aliases for installdirs options sub install_as_core { $_[0]->installdirs('perl') } sub install_as_cpan { $_[0]->installdirs('site') } sub install_as_site { $_[0]->installdirs('site') } sub install_as_vendor { $_[0]->installdirs('vendor') } sub dynamic_config { my $self = shift; my $value = @_ ? shift : 1; if ( $self->{values}->{dynamic_config} ) { # Once dynamic we never change to static, for safety return 0; } $self->{values}->{dynamic_config} = $value ? 1 : 0; return 1; } # Convenience command sub static_config { shift->dynamic_config(0); } sub perl_version { my $self = shift; return $self->{values}->{perl_version} unless @_; my $version = shift or die( "Did not provide a value to perl_version()" ); # Normalize the version $version = $self->_perl_version($version); # We don't support the really old versions unless ( $version >= 5.005 ) { die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n"; } $self->{values}->{perl_version} = $version; } sub all_from { my ( $self, $file ) = @_; unless ( defined($file) ) { my $name = $self->name or die( "all_from called with no args without setting name() first" ); $file = join('/', 'lib', split(/-/, $name)) . '.pm'; $file =~ s{.*/}{} unless -e $file; unless ( -e $file ) { die("all_from cannot find $file from $name"); } } unless ( -f $file ) { die("The path '$file' does not exist, or is not a file"); } $self->{values}{all_from} = $file; # Some methods pull from POD instead of code. # If there is a matching .pod, use that instead my $pod = $file; $pod =~ s/\.pm$/.pod/i; $pod = $file unless -e $pod; # Pull the different values $self->name_from($file) unless $self->name; $self->version_from($file) unless $self->version; $self->perl_version_from($file) unless $self->perl_version; $self->author_from($pod) unless @{$self->author || []}; $self->license_from($pod) unless $self->license; $self->abstract_from($pod) unless $self->abstract; return 1; } sub provides { my $self = shift; my $provides = ( $self->{values}->{provides} ||= {} ); %$provides = (%$provides, @_) if @_; return $provides; } sub auto_provides { my $self = shift; return $self unless $self->is_admin; unless (-e 'MANIFEST') { warn "Cannot deduce auto_provides without a MANIFEST, skipping\n"; return $self; } # Avoid spurious warnings as we are not checking manifest here. local $SIG{__WARN__} = sub {1}; require ExtUtils::Manifest; local *ExtUtils::Manifest::manicheck = sub { return }; require Module::Build; my $build = Module::Build->new( dist_name => $self->name, dist_version => $self->version, license => $self->license, ); $self->provides( %{ $build->find_dist_packages || {} } ); } sub feature { my $self = shift; my $name = shift; my $features = ( $self->{values}->{features} ||= [] ); my $mods; if ( @_ == 1 and ref( $_[0] ) ) { # The user used ->feature like ->features by passing in the second # argument as a reference. Accomodate for that. $mods = $_[0]; } else { $mods = \@_; } my $count = 0; push @$features, ( $name => [ map { ref($_) ? ( ref($_) eq 'HASH' ) ? %$_ : @$_ : $_ } @$mods ] ); return @$features; } sub features { my $self = shift; while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) { $self->feature( $name, @$mods ); } return $self->{values}->{features} ? @{ $self->{values}->{features} } : (); } sub no_index { my $self = shift; my $type = shift; push @{ $self->{values}->{no_index}->{$type} }, @_ if $type; return $self->{values}->{no_index}; } sub read { my $self = shift; $self->include_deps( 'YAML::Tiny', 0 ); require YAML::Tiny; my $data = YAML::Tiny::LoadFile('META.yml'); # Call methods explicitly in case user has already set some values. while ( my ( $key, $value ) = each %$data ) { next unless $self->can($key); if ( ref $value eq 'HASH' ) { while ( my ( $module, $version ) = each %$value ) { $self->can($key)->($self, $module => $version ); } } else { $self->can($key)->($self, $value); } } return $self; } sub write { my $self = shift; return $self unless $self->is_admin; $self->admin->write_meta; return $self; } sub version_from { require ExtUtils::MM_Unix; my ( $self, $file ) = @_; $self->version( ExtUtils::MM_Unix->parse_version($file) ); # for version integrity check $self->makemaker_args( VERSION_FROM => $file ); } sub abstract_from { require ExtUtils::MM_Unix; my ( $self, $file ) = @_; $self->abstract( bless( { DISTNAME => $self->name }, 'ExtUtils::MM_Unix' )->parse_abstract($file) ); } # Add both distribution and module name sub name_from { my ($self, $file) = @_; if ( Module::Install::_read($file) =~ m/ ^ \s* package \s* ([\w:]+) [\s|;]* /ixms ) { my ($name, $module_name) = ($1, $1); $name =~ s{::}{-}g; $self->name($name); unless ( $self->module_name ) { $self->module_name($module_name); } } else { die("Cannot determine name from $file\n"); } } sub _extract_perl_version { if ( $_[0] =~ m/ ^\s* (?:use|require) \s* v? ([\d_\.]+) \s* ; /ixms ) { my $perl_version = $1; $perl_version =~ s{_}{}g; return $perl_version; } else { return; } } sub perl_version_from { my $self = shift; my $perl_version=_extract_perl_version(Module::Install::_read($_[0])); if ($perl_version) { $self->perl_version($perl_version); } else { warn "Cannot determine perl version info from $_[0]\n"; return; } } sub author_from { my $self = shift; my $content = Module::Install::_read($_[0]); if ($content =~ m/ =head \d \s+ (?:authors?)\b \s* ([^\n]*) | =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s* .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s* ([^\n]*) /ixms) { my $author = $1 || $2; # XXX: ugly but should work anyway... if (eval "require Pod::Escapes; 1") { # Pod::Escapes has a mapping table. # It's in core of perl >= 5.9.3, and should be installed # as one of the Pod::Simple's prereqs, which is a prereq # of Pod::Text 3.x (see also below). $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } { defined $2 ? chr($2) : defined $Pod::Escapes::Name2character_number{$1} ? chr($Pod::Escapes::Name2character_number{$1}) : do { warn "Unknown escape: E<$1>"; "E<$1>"; }; }gex; } elsif (eval "require Pod::Text; 1" && $Pod::Text::VERSION < 3) { # Pod::Text < 3.0 has yet another mapping table, # though the table name of 2.x and 1.x are different. # (1.x is in core of Perl < 5.6, 2.x is in core of # Perl < 5.9.3) my $mapping = ($Pod::Text::VERSION < 2) ? \%Pod::Text::HTML_Escapes : \%Pod::Text::ESCAPES; $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } { defined $2 ? chr($2) : defined $mapping->{$1} ? $mapping->{$1} : do { warn "Unknown escape: E<$1>"; "E<$1>"; }; }gex; } else { $author =~ s{E}{<}g; $author =~ s{E}{>}g; } $self->author($author); } else { warn "Cannot determine author info from $_[0]\n"; } } #Stolen from M::B my %license_urls = ( perl => 'http://dev.perl.org/licenses/', apache => 'http://apache.org/licenses/LICENSE-2.0', apache_1_1 => 'http://apache.org/licenses/LICENSE-1.1', artistic => 'http://opensource.org/licenses/artistic-license.php', artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php', lgpl => 'http://opensource.org/licenses/lgpl-license.php', lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php', lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html', bsd => 'http://opensource.org/licenses/bsd-license.php', gpl => 'http://opensource.org/licenses/gpl-license.php', gpl2 => 'http://opensource.org/licenses/gpl-2.0.php', gpl3 => 'http://opensource.org/licenses/gpl-3.0.html', mit => 'http://opensource.org/licenses/mit-license.php', mozilla => 'http://opensource.org/licenses/mozilla1.1.php', open_source => undef, unrestricted => undef, restrictive => undef, unknown => undef, ); sub license { my $self = shift; return $self->{values}->{license} unless @_; my $license = shift or die( 'Did not provide a value to license()' ); $license = __extract_license($license) || lc $license; $self->{values}->{license} = $license; # Automatically fill in license URLs if ( $license_urls{$license} ) { $self->resources( license => $license_urls{$license} ); } return 1; } sub _extract_license { my $pod = shift; my $matched; return __extract_license( ($matched) = $pod =~ m/ (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?) (=head \d.*|=cut.*|)\z /xms ) || __extract_license( ($matched) = $pod =~ m/ (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?) (=head \d.*|=cut.*|)\z /xms ); } sub __extract_license { my $license_text = shift or return; my @phrases = ( '(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1, '(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1, 'Artistic and GPL' => 'perl', 1, 'GNU general public license' => 'gpl', 1, 'GNU public license' => 'gpl', 1, 'GNU lesser general public license' => 'lgpl', 1, 'GNU lesser public license' => 'lgpl', 1, 'GNU library general public license' => 'lgpl', 1, 'GNU library public license' => 'lgpl', 1, 'GNU Free Documentation license' => 'unrestricted', 1, 'GNU Affero General Public License' => 'open_source', 1, '(?:Free)?BSD license' => 'bsd', 1, 'Artistic license 2\.0' => 'artistic_2', 1, 'Artistic license' => 'artistic', 1, 'Apache (?:Software )?license' => 'apache', 1, 'GPL' => 'gpl', 1, 'LGPL' => 'lgpl', 1, 'BSD' => 'bsd', 1, 'Artistic' => 'artistic', 1, 'MIT' => 'mit', 1, 'Mozilla Public License' => 'mozilla', 1, 'Q Public License' => 'open_source', 1, 'OpenSSL License' => 'unrestricted', 1, 'SSLeay License' => 'unrestricted', 1, 'zlib License' => 'open_source', 1, 'proprietary' => 'proprietary', 0, ); while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) { $pattern =~ s#\s+#\\s+#gs; if ( $license_text =~ /\b$pattern\b/i ) { return $license; } } return ''; } sub license_from { my $self = shift; if (my $license=_extract_license(Module::Install::_read($_[0]))) { $self->license($license); } else { warn "Cannot determine license info from $_[0]\n"; return 'unknown'; } } sub _extract_bugtracker { my @links = $_[0] =~ m#L<( https?\Q://rt.cpan.org/\E[^>]+| https?\Q://github.com/\E[\w_]+/[\w_]+/issues| https?\Q://code.google.com/p/\E[\w_\-]+/issues/list )>#gx; my %links; @links{@links}=(); @links=keys %links; return @links; } sub bugtracker_from { my $self = shift; my $content = Module::Install::_read($_[0]); my @links = _extract_bugtracker($content); unless ( @links ) { warn "Cannot determine bugtracker info from $_[0]\n"; return 0; } if ( @links > 1 ) { warn "Found more than one bugtracker link in $_[0]\n"; return 0; } # Set the bugtracker bugtracker( $links[0] ); return 1; } sub requires_from { my $self = shift; my $content = Module::Install::_readperl($_[0]); my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+(v?[\d\.]+)/mg; while ( @requires ) { my $module = shift @requires; my $version = shift @requires; $self->requires( $module => $version ); } } sub test_requires_from { my $self = shift; my $content = Module::Install::_readperl($_[0]); my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg; while ( @requires ) { my $module = shift @requires; my $version = shift @requires; $self->test_requires( $module => $version ); } } # Convert triple-part versions (eg, 5.6.1 or 5.8.9) to # numbers (eg, 5.006001 or 5.008009). # Also, convert double-part versions (eg, 5.8) sub _perl_version { my $v = $_[-1]; $v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e; $v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e; $v =~ s/(\.\d\d\d)000$/$1/; $v =~ s/_.+$//; if ( ref($v) ) { # Numify $v = $v + 0; } return $v; } sub add_metadata { my $self = shift; my %hash = @_; for my $key (keys %hash) { warn "add_metadata: $key is not prefixed with 'x_'.\n" . "Use appopriate function to add non-private metadata.\n" unless $key =~ /^x_/; $self->{values}->{$key} = $hash{$key}; } } ###################################################################### # MYMETA Support sub WriteMyMeta { die "WriteMyMeta has been deprecated"; } sub write_mymeta_yaml { my $self = shift; # We need YAML::Tiny to write the MYMETA.yml file unless ( eval { require YAML::Tiny; 1; } ) { return 1; } # Generate the data my $meta = $self->_write_mymeta_data or return 1; # Save as the MYMETA.yml file print "Writing MYMETA.yml\n"; YAML::Tiny::DumpFile('MYMETA.yml', $meta); } sub write_mymeta_json { my $self = shift; # We need JSON to write the MYMETA.json file unless ( eval { require JSON; 1; } ) { return 1; } # Generate the data my $meta = $self->_write_mymeta_data or return 1; # Save as the MYMETA.yml file print "Writing MYMETA.json\n"; Module::Install::_write( 'MYMETA.json', JSON->new->pretty(1)->canonical->encode($meta), ); } sub _write_mymeta_data { my $self = shift; # If there's no existing META.yml there is nothing we can do return undef unless -f 'META.yml'; # We need Parse::CPAN::Meta to load the file unless ( eval { require Parse::CPAN::Meta; 1; } ) { return undef; } # Merge the perl version into the dependencies my $val = $self->Meta->{values}; my $perl = delete $val->{perl_version}; if ( $perl ) { $val->{requires} ||= []; my $requires = $val->{requires}; # Canonize to three-dot version after Perl 5.6 if ( $perl >= 5.006 ) { $perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e } unshift @$requires, [ perl => $perl ]; } # Load the advisory META.yml file my @yaml = Parse::CPAN::Meta::LoadFile('META.yml'); my $meta = $yaml[0]; # Overwrite the non-configure dependency hashes delete $meta->{requires}; delete $meta->{build_requires}; delete $meta->{recommends}; if ( exists $val->{requires} ) { $meta->{requires} = { map { @$_ } @{ $val->{requires} } }; } if ( exists $val->{build_requires} ) { $meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } }; } return $meta; } 1; Git-PurePerl-0.53/inc/Module/Install/Win32.pm000644 000767 000024 00000003403 12770000242 021203 0ustar00dbrookstaff000000 000000 #line 1 package Module::Install::Win32; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.16'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } # determine if the user needs nmake, and download it if needed sub check_nmake { my $self = shift; $self->load('can_run'); $self->load('get_file'); require Config; return unless ( $^O eq 'MSWin32' and $Config::Config{make} and $Config::Config{make} =~ /^nmake\b/i and ! $self->can_run('nmake') ); print "The required 'nmake' executable not found, fetching it...\n"; require File::Basename; my $rv = $self->get_file( url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe', ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe', local_dir => File::Basename::dirname($^X), size => 51928, run => 'Nmake15.exe /o > nul', check_for => 'Nmake.exe', remove => 1, ); die <<'END_MESSAGE' unless $rv; ------------------------------------------------------------------------------- Since you are using Microsoft Windows, you will need the 'nmake' utility before installation. It's available at: http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe or ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe Please download the file manually, save it to a directory in %PATH% (e.g. C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to that directory, and run "Nmake15.exe" from there; that will create the 'nmake.exe' file needed by this module. You may then resume the installation process described in README. ------------------------------------------------------------------------------- END_MESSAGE } 1; Git-PurePerl-0.53/inc/Module/Install/WriteAll.pm000644 000767 000024 00000002376 12770000242 022034 0ustar00dbrookstaff000000 000000 #line 1 package Module::Install::WriteAll; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.16'; @ISA = qw{Module::Install::Base}; $ISCORE = 1; } sub WriteAll { my $self = shift; my %args = ( meta => 1, sign => 0, inline => 0, check_nmake => 1, @_, ); $self->sign(1) if $args{sign}; $self->admin->WriteAll(%args) if $self->is_admin; $self->check_nmake if $args{check_nmake}; unless ( $self->makemaker_args->{PL_FILES} ) { # XXX: This still may be a bit over-defensive... unless ($self->makemaker(6.25)) { $self->makemaker_args( PL_FILES => {} ) if -f 'Build.PL'; } } # Until ExtUtils::MakeMaker support MYMETA.yml, make sure # we clean it up properly ourself. $self->realclean_files('MYMETA.yml'); if ( $args{inline} ) { $self->Inline->write; } else { $self->Makefile->write; } # The Makefile write process adds a couple of dependencies, # so write the META.yml files after the Makefile. if ( $args{meta} ) { $self->Meta->write; } # Experimental support for MYMETA if ( $ENV{X_MYMETA} ) { if ( $ENV{X_MYMETA} eq 'JSON' ) { $self->Meta->write_mymeta_json; } else { $self->Meta->write_mymeta_yaml; } } return 1; } 1;