[Bps-public-commit] Config-GitLike branch, master, updated. 1.08-17-gd2f0cf0
Alex Vandiver
alexmv at bestpractical.com
Fri Aug 10 03:36:10 EDT 2012
The branch, master has been updated
via d2f0cf0a70826bddab2f3e7fc8143420f315589c (commit)
via 2b79baca487954b61bddb8c6acf71ea1b485bf1d (commit)
via 73c8d8ef828ed25b1e104fb7123b98f2c2df19d8 (commit)
via 9e678e14e88fc3140da483a843ef431cb73c68ea (commit)
from 90ef3ed1b9667eb3d9b897e408b0da777607317c (commit)
Summary of changes:
.gitignore | 1 +
Changes | 10 +++++++
MANIFEST.SKIP | 1 +
lib/Config/GitLike.pm | 75 +++++++++++++++++++++++++--------------------------
4 files changed, 49 insertions(+), 38 deletions(-)
- Log -----------------------------------------------------------------
commit 9e678e14e88fc3140da483a843ef431cb73c68ea
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Aug 10 03:20:12 2012 -0400
Enforce that all keys must have sections
Previously, git correctly parsed configuration variables before the
first section marker, although it coult not set or unset such keys. In
git 1.7.4.4 and later, the code was modified to match the documentation,
and this misfeature was removed.
Alter the parsing code and methods to enforce this restriction in the
module as well, for consistency with git.
diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index 158b3f0..1a005b1 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -295,6 +295,10 @@ sub parse_content {
#
# in compatible mode, keys can contain only 0-9a-z-
elsif ($c =~ s/$key_regex//) {
+ return $args{error}->(
+ content => $args{content},
+ offset => $offset,
+ ) unless defined $section;
$args{callback}->(
section => $section,
name => lc $1,
@@ -305,6 +309,10 @@ sub parse_content {
# key/value pairs (this particular regex matches only the key part and
# the =, with unlimited whitespace around the =)
elsif ($c =~ s/$key_value_regex//) {
+ return $args{error}->(
+ content => $args{content},
+ offset => $offset,
+ ) unless defined $section;
my $name = lc $1;
my $value = "";
# parse the value
@@ -404,9 +412,9 @@ sub define {
origin => undef,
@_,
);
- return unless defined $args{name};
+ return unless defined $args{section} and defined $args{name};
$args{name} = lc $args{name};
- my $key = join(".", grep {defined} @args{qw/section name/});
+ my $key = join(".", @args{qw/section name/});
# we're either adding a whole new key or adding a multiple key from
# the same file
@@ -715,24 +723,19 @@ sub _split_key {
$section = $key;
}
else {
- $key =~ /^(?:(.*)\.)?(.*)$/;
+ $key =~ /^(.*)\.(.*)$/;
# If we wanted, we could interpret quoting of the section name to
# allow for setting keys with section names including . characters.
# But git-config doesn't do that, so we won't bother for now. (Right
# now it will read these section names correctly but won't set them.)
- ($section, $name) = map { _remove_balanced_quotes($_) }
- grep { defined $_ } ($1, $2);
+ ($section, $name) = map { _remove_balanced_quotes($_) } ($1, $2);
}
# Make sure the section name we're comparing against has
# case-insensitive section names and case-sensitive subsection names.
- if (defined $section) {
- $section =~ m/^([^.]+)(?:\.(.*))?$/;
- ($section, $subsection) = ($1, $2);
- }
- else {
- ($section, $subsection) = (undef) x 2;
- }
+ $section =~ m/^([^.]+)(?:\.(.*))?$/;
+ ($section, $subsection) = ($1, $2);
+
return ($section, $subsection, $name);
}
@@ -748,13 +751,9 @@ sub group_set {
my %args = %{$args_hash};
my ($section, $subsection, $name) = _split_key($args{key});
- my $key;
- {
- no warnings 'uninitialized';
- $key = join( '.',
- grep { defined } (lc $section, $subsection, lc $name),
- );
- }
+ my $key = join( '.',
+ grep { defined } (lc $section, $subsection, lc $name),
+ );
$args{multiple} = $self->is_multiple($key)
unless defined $args{multiple};
@@ -1703,7 +1702,7 @@ Given a section, a key name, and a value¸ store this information
in memory in the config object.
Returns the value that was just defined on success, or undef
-if no name is given and thus the key cannot be defined.
+if no name and section were given and thus the key cannot be defined.
=head2 cast
commit 73c8d8ef828ed25b1e104fb7123b98f2c2df19d8
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Aug 10 03:31:04 2012 -0400
Move add_comment POD to a more sensible place
diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index 1a005b1..80bfe28 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -1532,6 +1532,23 @@ Parameters:
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 add_comment
+
+Parameters:
+
+ comment => "Begin editing here\n and then stop",
+ filename => '/file/to/edit'
+ indented => 1,
+ semicolon => 0,
+
+Add a comment to the specified configuration file. The C<comment> and
+C<filename> parameters are required. Comments will be added to the file with
+C<# > at the begnning of each line of the comment. Pass a true value to
+C<semicolon> if you'd rather they start with C<; >. If your comments are
+indented with leading white space, and you want that white space to appear in
+front of the comment character, rather than after, pass a true value to
+C<indented>.
+
=head2 cascade( $bool )
Gets or sets if only the B<deepest> configuration file in a directory
@@ -1583,23 +1600,6 @@ version of this subroutine.
Returns nothing of note.
-=head2 add_comment
-
-Parameters:
-
- comment => "Begin editing here\n and then stop",
- filename => '/file/to/edit'
- indented => 1,
- semicolon => 0,
-
-Add a comment to the specified configuration file. The C<comment> and
-C<filename> parameters are required. Comments will be added to the file with
-C<# > at the begnning of each line of the comment. Pass a true value to
-C<semicolon> if you'd rather they start with C<; >. If your comments are
-indented with leading white space, and you want that white space to appear in
-front of the comment character, rather than after, pass a true value to
-C<indented>.
-
=head1 OTHER METHODS
These are mostly used internally in other methods, but could be useful anyway.
commit 2b79baca487954b61bddb8c6acf71ea1b485bf1d
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Aug 10 03:34:49 2012 -0400
Ignore generated MYMETA files
diff --git a/.gitignore b/.gitignore
index 9d897ac..da67780 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@
/META.yml
/cover_db/
/Config-GitLike-*
+/MYMETA.*
\ No newline at end of file
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP
index b36931c..8db2399 100644
--- a/MANIFEST.SKIP
+++ b/MANIFEST.SKIP
@@ -13,3 +13,4 @@
^MANIFEST.SKIP
^cover_db/
^Config-GitLike-*
+^MYMETA.*
\ No newline at end of file
commit d2f0cf0a70826bddab2f3e7fc8143420f315589c
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Aug 10 03:35:11 2012 -0400
Version 1.09 releng
diff --git a/Changes b/Changes
index 8a68808..affb430 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,13 @@
+1.09 2012-08-10
+
+* Multiple bug fixes concerning filters, including empty filters,
+ valueless keys, and applying filters to single values.
+* Add "human" argument to get_all and get_regexp, to match get
+* Add an add_comment method
+* Add an encoding attribute, which adds the appropriate layer on file
+ I/O
+* Enforce that all keys must have sections, as git 1.7.4.4 began doing
+
1.08 2012-02-15
* Fix loading of user_file, broken in dcdd01f, due to unexpanded ~
diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index 80bfe28..8894466 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -7,7 +7,7 @@ use Scalar::Util qw(openhandle);
use Fcntl qw(O_CREAT O_EXCL O_WRONLY);
use 5.008;
-our $VERSION = '1.08';
+our $VERSION = '1.09';
has 'confname' => (
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list