[Bps-public-commit] Config-GitLike branch, master, updated. 1.18

Alex Vandiver alexmv at bestpractical.com
Fri Mar 13 02:30:30 EDT 2020


The branch, master has been updated
       via  a065320af482d33142116f8ecf67606bdb9da48d (commit)
       via  b87df37d099147edec11e9fcca0b7b8a45805098 (commit)
      from  c11d7f609871ea0b55c7d5a9db9581c6934db554 (commit)

Summary of changes:
 Changes                   |  5 +++++
 lib/Config/GitLike.pm     |  6 ++++--
 lib/Config/GitLike/Git.pm | 15 ++++++++++++++-
 3 files changed, 23 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit b87df37d099147edec11e9fcca0b7b8a45805098
Author: Alex Vandiver <alex at chmrr.net>
Date:   Thu Mar 12 22:58:46 2020 -0700

    Return a more correct `dir_file` for Config::GitLike::Git
    
    Previously, the documentation claimed it returned `.git/config`, but
    actually returned `.gitconfig`. This is particularly inconvenient when
    doing a read/modify/write of a file in-place.
    
    Return `.git/config` from `dir_file` if called with no argument.  This
    change is not backwards-compatible, but is more correct to the
    expected use, and the documentation.
    
    If passed an optional directory path, `dir_file` now returns the
    fully-qualified path to the config file that would have been loaded
    from; this allows it to be used in bare repository directories
    correctly.
    
    Fixes #14.

diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index ae8b545..202fe8f 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -1682,7 +1682,9 @@ precedence, you'll need to override L<"load"> as well.
 =head2 dir_file
 
 Return a string containing the path to a configuration file with the
-name C<confname> in a directory. The directory isn't specified here.
+name C<confname> in a directory.  Called with no arguments,
+returns the path for a generic directory; if called with a
+directory as an argument, returns the path for I<that> directory.
 
 =head2 global_file
 
diff --git a/lib/Config/GitLike/Git.pm b/lib/Config/GitLike/Git.pm
index 492195c..2169273 100644
--- a/lib/Config/GitLike/Git.pm
+++ b/lib/Config/GitLike/Git.pm
@@ -13,6 +13,17 @@ has '+compatible' => (
     default => 1,
 );
 
+sub dir_file {
+    my $self = shift;
+    return ".git/config" unless @_;
+    my $path = shift;
+    my $dir = $self->is_git_dir( $path );
+    return File::Spec->catfile( $dir, "config" ) if $dir;
+
+    $path = File::Spec->rel2abs( $path );
+    return File::Spec->catfile( $path, ".git/config");
+}
+
 sub is_git_dir {
     my $self = shift;
     my $path = File::Spec->rel2abs( shift );
@@ -83,7 +94,9 @@ This module overrides these methods from C<Config::GitLike>:
 
 =head2 dir_file
 
-The per-directory configuration file is F<.git/config>
+The per-directory configuration file is F<.git/config>.  With an
+optional directory argument, will return a fully-qualified path to the
+configuration file, as git would edit with C<git config --local -C path>.
 
 =head2 user_file
 

commit a065320af482d33142116f8ecf67606bdb9da48d
Author: Alex Vandiver <alex at chmrr.net>
Date:   Thu Mar 12 23:07:02 2020 -0700

    Version 1.18 releng

diff --git a/Changes b/Changes
index 1e230aa..be5e035 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,10 @@
 Revision history for perl module Config::GitLike
 
+1.18 2020-03-12
+ - Return a more correct `dir_file` for Config::GitLike::Git; this
+   change is not backwards-compatible, but matches behavior to existing
+   documentation and expectation.
+
 1.17 2017-07-16
  - Read and write files with non-UNIX-newlines
  - Filter multiple values correctly when using `get_regexp`
diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index 202fe8f..620ab62 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -8,7 +8,7 @@ use Scalar::Util qw(openhandle);
 use Fcntl qw(O_CREAT O_EXCL O_WRONLY);
 use 5.008;
 
-our $VERSION = '1.17';
+our $VERSION = '1.18';
 
 
 has 'confname' => (

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list