r55372 - in /branches/upstream/libconfig-gitlike-perl/current: Changes MANIFEST META.yml SIGNATURE lib/Config/GitLike.pm lib/Config/GitLike/Cascaded.pm lib/Config/GitLike/Git.pm

chrisb at users.alioth.debian.org chrisb at users.alioth.debian.org
Sat Apr 3 12:09:55 UTC 2010


Author: chrisb
Date: Sat Apr  3 12:09:30 2010
New Revision: 55372

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=55372
Log:
[svn-upgrade] Integrating new upstream version, libconfig-gitlike-perl (1.04)

Modified:
    branches/upstream/libconfig-gitlike-perl/current/Changes
    branches/upstream/libconfig-gitlike-perl/current/MANIFEST
    branches/upstream/libconfig-gitlike-perl/current/META.yml
    branches/upstream/libconfig-gitlike-perl/current/SIGNATURE
    branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike.pm
    branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike/Cascaded.pm
    branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike/Git.pm

Modified: branches/upstream/libconfig-gitlike-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconfig-gitlike-perl/current/Changes?rev=55372&op=diff
==============================================================================
--- branches/upstream/libconfig-gitlike-perl/current/Changes (original)
+++ branches/upstream/libconfig-gitlike-perl/current/Changes Sat Apr  3 12:09:30 2010
@@ -1,11 +1,24 @@
+1.04 - 2010-04-03
+
+* The functionality of Config::GitLike::Cascaded has been folded into
+  Config::GitLike as a "cascade" option, and the subpackage is now
+  deprecated. (alexmv)
+* Config::GitLike::Git->new->load("/path/to/git") when the path is
+  lacking a ".git", or is a bare repository, now works. (alexmv)
+* Fixed a bug wherein the home directory config file would be loaded
+  twice, causing all values to be multiple, if that was your cwd.
+  Reported by rjbs. (alexmv)
+* Allow explicitly calling ->load_file without previously having
+  called ->load (alexmv)
+
 1.03 - 2010-01-03
 
-*  Filter without replace_all should only replace the _first_ match (alexmv)
-*  Having a matching filter with multiple and not replace_all does mean
-   replacement (alexmv)
-*  Fix a test that failed because multiple now works, and we're too smart
-   (alexmv)
-*  Fix for when ->set_multiple called with no arguments (alexmv)
+* Filter without replace_all should only replace the _first_ match (alexmv)
+* Having a matching filter with multiple and not replace_all does mean
+  replacement (alexmv)
+* Fix a test that failed because multiple now works, and we're too smart
+  (alexmv)
+* Fix for when ->set_multiple called with no arguments (alexmv)
 
 1.02 - 2009-08-19
 

Modified: branches/upstream/libconfig-gitlike-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconfig-gitlike-perl/current/MANIFEST?rev=55372&op=diff
==============================================================================
--- branches/upstream/libconfig-gitlike-perl/current/MANIFEST (original)
+++ branches/upstream/libconfig-gitlike-perl/current/MANIFEST Sat Apr  3 12:09:30 2010
@@ -13,8 +13,8 @@
 Makefile.PL
 MANIFEST			This list of files
 META.yml
-SIGNATURE
 t/00_use.t
 t/lib/TestConfig.pm
 t/t1300-repo-config.t
 t/util/translate.pl
+SIGNATURE                                Public-key signature (added by MakeMaker)

Modified: branches/upstream/libconfig-gitlike-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconfig-gitlike-perl/current/META.yml?rev=55372&op=diff
==============================================================================
--- branches/upstream/libconfig-gitlike-perl/current/META.yml (original)
+++ branches/upstream/libconfig-gitlike-perl/current/META.yml Sat Apr  3 12:09:30 2010
@@ -28,4 +28,4 @@
 resources:
   license: http://dev.perl.org/licenses/
   repository: http://github.com/bestpractical/config-gitlike
-version: 1.03
+version: 1.04

Modified: branches/upstream/libconfig-gitlike-perl/current/SIGNATURE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconfig-gitlike-perl/current/SIGNATURE?rev=55372&op=diff
==============================================================================
--- branches/upstream/libconfig-gitlike-perl/current/SIGNATURE (original)
+++ branches/upstream/libconfig-gitlike-perl/current/SIGNATURE Sat Apr  3 12:09:30 2010
@@ -12,11 +12,11 @@
 not run its Makefile.PL or Build.PL.
 
 -----BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA256
+Hash: SHA1
 
-SHA1 2daac330ae24db9a46c2d79a12d66f63c269af71 Changes
-SHA1 e64d07b95f1af7d671d5d4a3d5cbe4f204dcc801 MANIFEST
-SHA1 8c2a9bb6ed304bf00b883bdcd3adbd4e9fef9e74 META.yml
+SHA1 44eef7b9124a89ff64566ca02bf2806fd6fde63b Changes
+SHA1 37111fe4f5de6afc374ebc74683eb77cc96bc5ec MANIFEST
+SHA1 62fe2f5b8797b6d85fc4f7897b91cd5aec9a02d7 META.yml
 SHA1 652f43d3bb9a33ac5995713dee8716c4d384242f Makefile.PL
 SHA1 fd5f3c4f0418efee3b9b16cf8c3902e8374909df inc/Module/Install.pm
 SHA1 7cd7c349afdf3f012e475507b1017bdfa796bfbd inc/Module/Install/Base.pm
@@ -26,27 +26,17 @@
 SHA1 12bf1867955480d47d5171a9e9c6a96fabe0b58f inc/Module/Install/Metadata.pm
 SHA1 f7ee667e878bd2faf22ee9358a7b5a2cc8e91ba4 inc/Module/Install/Win32.pm
 SHA1 8ed29d6cf217e0977469575d788599cbfb53a5ca inc/Module/Install/WriteAll.pm
-SHA1 1cf3f261b0086c2571db24c6045793cc7ef0b45b lib/Config/GitLike.pm
-SHA1 9426d508e6841b28449fd5bda97abd1b4f0cbe19 lib/Config/GitLike/Cascaded.pm
-SHA1 5444576afe2536921e404e87023181f70f37cc75 lib/Config/GitLike/Git.pm
+SHA1 73154d46c1e58f11b9c162b5682fc2342cd5b26c lib/Config/GitLike.pm
+SHA1 7085bda091bd2504987e9519a9788bcf63d339ef lib/Config/GitLike/Cascaded.pm
+SHA1 2bb7a846da36b117abf39194033bb1bbdb076c45 lib/Config/GitLike/Git.pm
 SHA1 8c30f69743e7a9d743d7206f2306ff9f12bb59a0 t/00_use.t
 SHA1 cde69d95c8c39de4f9816b7bfb845b2d96554a7e t/lib/TestConfig.pm
 SHA1 7e5420d1d658a8ccced4d55287b454cd8a7fea7f t/t1300-repo-config.t
 SHA1 53b21b0f0227909dd299d8adb033f5aff8f5fc42 t/util/translate.pl
 -----BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.10 (GNU/Linux)
+Version: GnuPG v2.0.14 (GNU/Linux)
 
-iQIcBAEBCAAGBQJLQMfUAAoJEGSVn+mDjfGcNaAP+gJzpEZFAwdMFHK3dQkqRLkB
-7uG8ziaAiGSpjCDHmwRp8x/iHnqPTK6UZpIb6ZgUuzOhu1am/egjzhgW4GeDfQRx
-Gv8V0EXoctmvVD90b8G1LJRcyd1oVvHqJdhyemgmKVO5/w5LzFZmLHbtRJccN1wR
-+7K7+gxKa2z30ck3ex0KSv3ifVKAkINOaFwAqrfwwVoF+p5EVCMReoofG8jNycwE
-7xhkehWQPOZEnz5NhGqFcSiF1ixpB23mQavL8UJiPdDZCrlOVGnRPMVQGevLK3ZC
-vyVlvGOc0LJJzIhFDWiMlJ/dittf/0EY5oXesmZp+HOlJCx3y8lhIF7sP+PqCYsi
-7Hdk383mvCTWekw8w7vY0KJEfCfYyCZuKfgATRZZBaeFFR57uW/Wd0bj3QPGKDxX
-LYnNrbJ2pPdIVUv47p6EFBqDrFiElbV9Ov0fiZEPXKcyUUI3tQs++CVDHxZdy0oH
-mQaqkJ4zlbr249sozVoUztN9dRflTIg+jYH3QCUhHTmsiLPpYBJi12FRgSDYpZs1
-pt2Q9Yi9+R26UuYkykVqbmoL3mvP8BQISEM8QspYTVsA44P0VlijsSIdx9IyDAOu
-BTzfQc0HuaVUJp81SkRt0us9d0Y0tyOieci+HftFCW0WyD0VKEfHWS2CUtRSbOus
-fkZS2Oxqu4tULAtAJgec
-=ylIC
+iEYEARECAAYFAku20GwACgkQMflWJZZAbqA7SACcCCobP0fG5YN4bMNSohtv5XGw
+Gm8AoMZc1IWrzZGPVfKwxiTK0MbN1NLW
+=zyGq
 -----END PGP SIGNATURE-----

Modified: branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike.pm?rev=55372&op=diff
==============================================================================
--- branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike.pm (original)
+++ branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike.pm Sat Apr  3 12:09:30 2010
@@ -7,7 +7,7 @@
 use Fcntl qw(O_CREAT O_EXCL O_WRONLY);
 use 5.008;
 
-our $VERSION = '1.03';
+our $VERSION = '1.04';
 
 
 has 'confname' => (
@@ -47,6 +47,12 @@
 # default to being more relaxed than git, but allow enforcement
 # of only-write-things-that-git-config-can-read if you want to
 has 'compatible' => (
+    is => 'rw',
+    isa => 'Bool',
+    default => 0,
+);
+
+has 'cascade' => (
     is => 'rw',
     isa => 'Bool',
     default => 0,
@@ -87,16 +93,18 @@
     my $path = shift;
     my($vol, $dirs, undef) = File::Spec->splitpath( $path, 1 );
     my @dirs = File::Spec->splitdir( $dirs );
+    my @found;
     while (@dirs) {
         my $path = File::Spec->catpath(
             $vol, File::Spec->catdir(@dirs), $self->dir_file
         );
         if (-f $path) {
-            $self->load_file( $path );
-            last;
+            push @found, $path;
+            last unless $self->cascade;
         }
         pop @dirs;
     }
+    $self->load_file( $_ ) for reverse @found;
 }
 
 sub global_file {
@@ -139,8 +147,11 @@
 sub load_file {
     my $self = shift;
     my ($filename) = @_;
+    $self->data({}) unless $self->is_loaded;
+
+    return $self->data if grep {$_ eq $filename} @{$self->config_files};
+
     my $c = $self->_read_config($filename);
-
     $self->parse_content(
         content  => $c,
         callback => sub {
@@ -1296,7 +1307,7 @@
 =head2 config_filenames
 
 An array reference containing the absolute filenames of all config files
-that are currently loaded.
+that are currently loaded, in the order they were loaded.
 
 =head2 get
 
@@ -1436,6 +1447,12 @@
 Just a convenience wrapper around L<"rename_section"> for readability's sake.
 Removes the given section (which you can do by renaming to nothing as well).
 
+=head2 cascade( $bool )
+
+Gets or sets if only the B<deepest> configuration file in a directory
+tree is loaded, or if all of them are loaded, shallowest to deepest.
+Alternately, C<cascade =E<gt> 1> can be passed to C<new>.
+
 =head1 METHODS YOU MAY WISH TO OVERRIDE
 
 If your application's configuration layout is different from the default, e.g.
@@ -1670,8 +1687,8 @@
 =head1 SEE ALSO
 
 L<http://www.kernel.org/pub/software/scm/git/docs/git-config.html#_configuration_file>,
-L<Config::GitLike::Cascaded|Config::GitLike::Cascaded>, L<http://syncwith.us/>
-(C<Config::GitLike> is used in Prophet/SD and provides a working example)
+L<Config::GitLike::Git>, L<http://syncwith.us/> (C<Config::GitLike> is
+used in Prophet/SD and provides a working example)
 
 =head1 LICENSE
 
@@ -1680,7 +1697,7 @@
 
 =head1 COPYRIGHT
 
-Copyright 2009 Best Practical Solutions, LLC
+Copyright 2010 Best Practical Solutions, LLC
 
 =head1 AUTHORS
 

Modified: branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike/Cascaded.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike/Cascaded.pm?rev=55372&op=diff
==============================================================================
--- branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike/Cascaded.pm (original)
+++ branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike/Cascaded.pm Sat Apr  3 12:09:30 2010
@@ -5,16 +5,9 @@
 
 extends 'Config::GitLike';
 
-sub load_dirs {
-    my $self = shift;
-    my $path = shift;
-    my($vol, $dirs, undef) = File::Spec->splitpath( $path, 1 );
-    my @dirs = File::Spec->splitdir( $dirs );
-    for my $i ( 1 .. $#dirs ) {
-        my $path = File::Spec->catpath( $vol, File::Spec->catdir(@dirs[0..$i]), $self->dir_file );
-        $self->load_file( $path ) if -e $path;
-    }
-}
+has 'cascade' => (
+    default => 1,
+);
 
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
@@ -29,31 +22,13 @@
 
 =head1 SYNOPSIS
 
-B<Stop!> Do not pass go! Go directly to L<Config::GitLike|Config::GitLike> and read that
-instead. This is a minor variation on that which changes how the configuration
-loading works. Everything else is exactly the same. Just swap in
-C<Config::GitLike::Cascaded> where it reads C<Config::GitLike>.
+This module exists purely for backwards compatability; its use is
+deprecated, and will be removed in a future release.
 
 =head1 DESCRIPTION
 
-The only difference between this module and C<Config::GitLike> as that
-when it's loading the configuration file in the current directory, it
-keeps walking the directory tree even if it finds a config file,
-whereas C<Config::GitLike> will stop after finding the first.
-
-This allows us to have interesting cascading configuration inheritance.
-
-=head1 METHODS
-
-This module overrides this method from C<Config::GitLike>:
-
-=head2 load_dirs
-
-Load the configuration files in the directory tree, starting with the root
-directory and walking up to the current working directory. (No error is thrown
-if no config files are found.)
-
-Returns nothing of note.
+This module simply defaults L<Config::GitLike/cascaded> to a true
+value.
 
 =head1 SEE ALSO
 
@@ -66,7 +41,7 @@
 
 =head1 COPYRIGHT
 
-Copyright 2009 Best Practical Solutions, LLC
+Copyright 2010 Best Practical Solutions, LLC
 
 =head1 AUTHORS
 

Modified: branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike/Git.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike/Git.pm?rev=55372&op=diff
==============================================================================
--- branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike/Git.pm (original)
+++ branches/upstream/libconfig-gitlike-perl/current/lib/Config/GitLike/Git.pm Sat Apr  3 12:09:30 2010
@@ -1,30 +1,50 @@
 package Config::GitLike::Git;
 use Any::Moose;
+use strict;
+use warnings;
 
 extends 'Config::GitLike';
 
 has 'confname' => (
-    default => 'git',
+    default => 'gitconfig',
 );
 
 has 'compatible' => (
     default => 1,
 );
 
-sub dir_file {
+sub is_git_dir {
     my $self = shift;
-    return ".git/config";
+    my $path = File::Spec->rel2abs( shift );
+    $path =~ s{/+$}{};
+
+    ($path) = grep {-d} map {"$path$_"} (".git/.git", "/.git", ".git", "");
+    return unless $path;
+
+    # Has to have objects/ and refs/ directories
+    return unless -d "$path/objects" and -d "$path/refs";
+
+    # Has to have a HEAD file
+    return unless -f "$path/HEAD";
+
+    if (-l "$path/HEAD" ) {
+        # Symbolic link into refs/
+        return unless readlink("$path/HEAD") =~ m{^refs/};
+    } else {
+        open(HEAD, "$path/HEAD") or return;
+        my ($line) = <HEAD>;
+        close HEAD;
+        # Is either 'ref: refs/whatever' or a sha1
+        return unless $line =~ m{^(ref:\s*refs/|[0-9a-fA-F]{20})};
+    }
+    return $path;
 }
 
-sub user_file {
+sub load_dirs {
     my $self = shift;
-    return
-        File::Spec->catfile( $ENV{'HOME'}, ".gitconfig" );
-}
-
-sub global_file {
-    my $self = shift;
-    return "/etc/gitconfig";
+    my $path = shift;
+    my $dir = $self->is_git_dir($path) or return;
+    $self->load_file( File::Spec->catfile( $dir, "config" ) );
 }
 
 __PACKAGE__->meta->make_immutable;
@@ -42,14 +62,20 @@
 
     use Config::GitLike::Git;
     my $config = Config::GitLike::Git->new;
+    $config->load("/path/to/repo");
 
 =head1 DESCRIPTION
 
-This is a modification of L<Config::GitLike|Config::GitLike> to look at the
-same locations that Git writes to. Unlike with
-L<Config::GitLike|Config::GitLike>, you do not need to pass a confname to its
-constructor. This module also enables the L<Config::GitLike|Config::GitLike>
-option to maintain git compatibility when reading and writing variables.
+This is a modification of L<Config::GitLike> to look at the same
+locations that Git writes to. Unlike with L<Config::GitLike>, you do
+not need to pass a confname to its constructor. This module also
+enables the L<Config::GitLike> option to maintain git compatibility
+when reading and writing variables.
+
+L<Config::GitLike/load> should be passed path to the top level of a
+git repository -- this defaults to the current directory.  It will
+append C<.git> as necessary.  It supports both bare and non-bare
+repositories.
 
 =head1 METHODS
 
@@ -78,7 +104,7 @@
 
 =head1 COPYRIGHT
 
-Copyright 2009 Best Practical Solutions, LLC
+Copyright 2010 Best Practical Solutions, LLC
 
 =head1 AUTHORS
 




More information about the Pkg-perl-cvs-commits mailing list