Revision history for App-Codeowners.
+0.49 2020-03-22 01:30:54-06:00 MST7MDT
+ * Fix an encoding issue with the YAML formatter.
+ * Add rename_owner methods.
+
0.48 2020-01-21 10:13:14-07:00 MST7MDT
- * Add rename_project and update_owners_by_project functions.
+ * Add rename_project and update_owners_by_project methods.
* No changes to the CLI.
0.47 2019-11-17 17:36:49-07:00 MST7MDT
-# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.012.
+# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.014.
Changes
LICENSE
MANIFEST
"Charles McGarvey <chazmcgarvey@brokenzipper.com>"
],
"dynamic_config" : 0,
- "generated_by" : "Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010",
+ "generated_by" : "Dist::Zilla version 6.014, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"provides" : {
"App::Codeowners" : {
"file" : "lib/App/Codeowners.pm",
- "version" : "0.48"
+ "version" : "0.49"
},
"App::Codeowners::Formatter" : {
"file" : "lib/App/Codeowners/Formatter.pm",
- "version" : "0.48"
+ "version" : "0.49"
},
"App::Codeowners::Formatter::CSV" : {
"file" : "lib/App/Codeowners/Formatter/CSV.pm",
- "version" : "0.48"
+ "version" : "0.49"
},
"App::Codeowners::Formatter::JSON" : {
"file" : "lib/App/Codeowners/Formatter/JSON.pm",
- "version" : "0.48"
+ "version" : "0.49"
},
"App::Codeowners::Formatter::String" : {
"file" : "lib/App/Codeowners/Formatter/String.pm",
- "version" : "0.48"
+ "version" : "0.49"
},
"App::Codeowners::Formatter::TSV" : {
"file" : "lib/App/Codeowners/Formatter/TSV.pm",
- "version" : "0.48"
+ "version" : "0.49"
},
"App::Codeowners::Formatter::Table" : {
"file" : "lib/App/Codeowners/Formatter/Table.pm",
- "version" : "0.48"
+ "version" : "0.49"
},
"App::Codeowners::Formatter::YAML" : {
"file" : "lib/App/Codeowners/Formatter/YAML.pm",
- "version" : "0.48"
+ "version" : "0.49"
},
"App::Codeowners::Options" : {
"file" : "lib/App/Codeowners/Options.pm",
- "version" : "0.48"
+ "version" : "0.49"
},
"App::Codeowners::Util" : {
"file" : "lib/App/Codeowners/Util.pm",
- "version" : "0.48"
+ "version" : "0.49"
},
"App::Codeowners::Util::Process" : {
"file" : "lib/App/Codeowners/Util.pm",
- "version" : "0.48"
+ "version" : "0.49"
},
"File::Codeowners" : {
"file" : "lib/File/Codeowners.pm",
- "version" : "0.48"
+ "version" : "0.49"
},
"Test::File::Codeowners" : {
"file" : "lib/Test/File/Codeowners.pm",
- "version" : "0.48"
+ "version" : "0.49"
}
},
"release_status" : "stable",
"web" : "https://github.com/chazmcgarvey/git-codeowners"
}
},
- "version" : "0.48",
+ "version" : "0.49",
"x_authority" : "cpan:CCM",
"x_generated_by_perl" : "v5.28.0",
- "x_serialization_backend" : "Cpanel::JSON::XS version 4.15"
+ "x_serialization_backend" : "Cpanel::JSON::XS version 4.15",
+ "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later"
}
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 0
-generated_by: 'Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010'
+generated_by: 'Dist::Zilla version 6.014, CPAN::Meta::Converter version 2.150010'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
provides:
App::Codeowners:
file: lib/App/Codeowners.pm
- version: '0.48'
+ version: '0.49'
App::Codeowners::Formatter:
file: lib/App/Codeowners/Formatter.pm
- version: '0.48'
+ version: '0.49'
App::Codeowners::Formatter::CSV:
file: lib/App/Codeowners/Formatter/CSV.pm
- version: '0.48'
+ version: '0.49'
App::Codeowners::Formatter::JSON:
file: lib/App/Codeowners/Formatter/JSON.pm
- version: '0.48'
+ version: '0.49'
App::Codeowners::Formatter::String:
file: lib/App/Codeowners/Formatter/String.pm
- version: '0.48'
+ version: '0.49'
App::Codeowners::Formatter::TSV:
file: lib/App/Codeowners/Formatter/TSV.pm
- version: '0.48'
+ version: '0.49'
App::Codeowners::Formatter::Table:
file: lib/App/Codeowners/Formatter/Table.pm
- version: '0.48'
+ version: '0.49'
App::Codeowners::Formatter::YAML:
file: lib/App/Codeowners/Formatter/YAML.pm
- version: '0.48'
+ version: '0.49'
App::Codeowners::Options:
file: lib/App/Codeowners/Options.pm
- version: '0.48'
+ version: '0.49'
App::Codeowners::Util:
file: lib/App/Codeowners/Util.pm
- version: '0.48'
+ version: '0.49'
App::Codeowners::Util::Process:
file: lib/App/Codeowners/Util.pm
- version: '0.48'
+ version: '0.49'
File::Codeowners:
file: lib/File/Codeowners.pm
- version: '0.48'
+ version: '0.49'
Test::File::Codeowners:
file: lib/Test/File/Codeowners.pm
- version: '0.48'
+ version: '0.49'
recommends:
Pod::Usage: '0'
Term::Detect::Software: '0'
bugtracker: https://github.com/chazmcgarvey/git-codeowners/issues
homepage: https://github.com/chazmcgarvey/git-codeowners
repository: https://github.com/chazmcgarvey/git-codeowners.git
-version: '0.48'
+version: '0.49'
x_authority: cpan:CCM
x_generated_by_perl: v5.28.0
x_serialization_backend: 'YAML::Tiny version 1.73'
+x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later'
-# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.012.
+# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.014.
use strict;
use warnings;
"Test::Exit" => 0,
"Test::More" => 0
},
- "VERSION" => "0.48",
+ "VERSION" => "0.49",
"test" => {
"TESTS" => "t/*.t"
}
VERSION
- version 0.48
+ version 0.49
SYNOPSIS
use App::Codeowners;
-our $VERSION = '0.48'; # VERSION
+our $VERSION = '0.49'; # VERSION
App::Codeowners->main(@ARGV);
=head1 VERSION
-version 0.48
+version 0.49
=head1 SYNOPSIS
use App::Codeowners::Options;
use App::Codeowners::Util qw(find_codeowners_in_directory run_git git_ls_files git_toplevel);
use Color::ANSI::Util 0.03 qw(ansifg);
-use Encode qw(encode);
use File::Codeowners;
use Path::Tiny;
-our $VERSION = '0.48'; # VERSION
+our $VERSION = '0.49'; # VERSION
sub main {
my $command = $opts->command;
my $handler = $self->can("_command_$command")
or die "Unknown command: $command\n";
+
+ binmode(STDOUT, ':encoding(UTF-8)');
$self->$handler($opts);
exit 0;
=head1 VERSION
-version 0.48
+version 0.49
=head1 DESCRIPTION
use warnings;
use strict;
-our $VERSION = '0.48'; # VERSION
+our $VERSION = '0.49'; # VERSION
use Module::Load;
=head1 VERSION
-version 0.48
+version 0.49
=head1 SYNOPSIS
use warnings;
use strict;
-our $VERSION = '0.48'; # VERSION
+our $VERSION = '0.49'; # VERSION
use parent 'App::Codeowners::Formatter';
use App::Codeowners::Util qw(stringify);
-use Encode qw(encode);
sub start {
my $self = shift;
my $self = shift;
my $result = shift;
- $self->text_csv->print($self->handle, [map { encode('UTF-8', stringify($_)) } @$result]);
+ $self->text_csv->print($self->handle, [map { stringify($_) } @$result]);
}
=head1 VERSION
-version 0.48
+version 0.49
=head1 DESCRIPTION
use warnings;
use strict;
-our $VERSION = '0.48'; # VERSION
+our $VERSION = '0.49'; # VERSION
use parent 'App::Codeowners::Formatter';
my %options;
$options{pretty} = 1 if lc($self->format) eq 'pretty';
- my $json = JSON::MaybeXS->new(canonical => 1, utf8 => 1, %options);
+ my $json = JSON::MaybeXS->new(canonical => 1, %options);
my $columns = $self->columns;
$results = [map { +{zip @$columns, @$_} } @$results];
=head1 VERSION
-version 0.48
+version 0.49
=head1 DESCRIPTION
use warnings;
use strict;
-our $VERSION = '0.48'; # VERSION
+our $VERSION = '0.49'; # VERSION
use parent 'App::Codeowners::Formatter';
use App::Codeowners::Util qw(stringf zip);
use Color::ANSI::Util 0.03 qw(ansifg);
-use Encode qw(encode);
sub stream {
my $self = shift;
);
my $text = stringf($self->format, %info);
- print { $self->handle } encode('UTF-8', $text), "\n";
+ print { $self->handle } $text, "\n";
}
sub _expand_filter_args {
=head1 VERSION
-version 0.48
+version 0.49
=head1 DESCRIPTION
use warnings;
use strict;
-our $VERSION = '0.48'; # VERSION
+our $VERSION = '0.49'; # VERSION
use parent 'App::Codeowners::Formatter::CSV';
=head1 VERSION
-version 0.48
+version 0.49
=head1 DESCRIPTION
use warnings;
use strict;
-our $VERSION = '0.48'; # VERSION
+our $VERSION = '0.49'; # VERSION
use parent 'App::Codeowners::Formatter';
use App::Codeowners::Util qw(stringify);
-use Encode qw(encode);
sub finish {
my $self = shift;
rows => [$self->columns, map { [map { stringify($_) } @$_] } @$results],
backend => $ENV{PERL_TEXT_TABLE},
);
- print { $self->handle } encode('UTF-8', $table);
+ print { $self->handle } $table;
}
1;
=head1 VERSION
-version 0.48
+version 0.49
=head1 DESCRIPTION
use warnings;
use strict;
-our $VERSION = '0.48'; # VERSION
+our $VERSION = '0.49'; # VERSION
use parent 'App::Codeowners::Formatter';
=head1 VERSION
-version 0.48
+version 0.49
=head1 DESCRIPTION
use warnings;
use strict;
+use Encode qw(decode);
use Getopt::Long 2.39 ();
use Path::Tiny;
-our $VERSION = '0.48'; # VERSION
+our $VERSION = '0.49'; # VERSION
sub pod2usage {
eval { require Pod::Usage };
my $class = shift;
my @args = @_;
+ # assume UTF-8 args if non-ASCII
+ @args = map { decode('UTF-8', $_) } @args if grep { /\P{ASCII}/ } @args;
+
my $self = bless {}, $class;
my @args_copy = @args;
=head1 VERSION
-version 0.48
+version 0.49
=head1 METHODS
zip
);
-our $VERSION = '0.48'; # VERSION
+our $VERSION = '0.49'; # VERSION
sub find_nearest_codeowners {
=head1 VERSION
-version 0.48
+version 0.49
=head1 DESCRIPTION
use Scalar::Util qw(openhandle);
use Text::Gitignore qw(build_gitignore_matcher);
-our $VERSION = '0.48'; # VERSION
+our $VERSION = '0.49'; # VERSION
sub _croak { require Carp; Carp::croak(@_); }
sub _usage { _croak("Usage: @_\n") }
my $self = shift;
my $path = shift or _usage(q{$codeowners->write_to_filepath($filepath)});
- path($path)->spew_utf8([map { "$_\n" } @{$self->write_to_array('')}]);
+ path($path)->spew_utf8([map { "$_\n" } @{$self->write_to_array}]);
}
sub write_to_fh {
- my $self = shift;
- my $fh = shift or _usage(q{$codeowners->write_to_fh($fh)});
+ my $self = shift;
+ my $fh = shift or _usage(q{$codeowners->write_to_fh($fh)});
+ my $charset = shift;
- for my $line (@{$self->write_to_array}) {
+ for my $line (@{$self->write_to_array($charset)}) {
print $fh "$line\n";
}
}
sub write_to_string {
- my $self = shift;
+ my $self = shift;
+ my $charset = shift;
- my $str = join("\n", @{$self->write_to_array}) . "\n";
+ my $str = join("\n", @{$self->write_to_array($charset)}) . "\n";
return \$str;
}
sub write_to_array {
my $self = shift;
- my $charset = shift // 'UTF-8';
+ my $charset = shift;
my @format;
}
}
- if ($charset) {
+ if (defined $charset) {
$_ = encode($charset, $_) for @format;
}
return \@format;
}
+sub rename_owner {
+ my $self = shift;
+ my $old_owner = shift;
+ my $new_owner = shift;
+ $old_owner && $new_owner or _usage(q{$codeowners->rename_owner($owner => $new_owner)});
+
+ $self->_clear;
+
+ my $count = 0;
+
+ for my $line (@{$self->_lines}) {
+ next if !exists $line->{owners};
+ for (my $i = 0; $i < @{$line->{owners}}; ++$i) {
+ next if $line->{owners}[$i] ne $old_owner;
+ $line->{owners}[$i] = $new_owner;
+ ++$count;
+ }
+ }
+
+ return $count;
+}
+
+
sub rename_project {
my $self = shift;
my $old_project = shift;
=head1 VERSION
-version 0.48
+version 0.49
=head1 METHODS
Nothing happens if the file does not have a project with the given name.
+=head2 rename_owner
+
+ $codeowners->rename_owner($old_name => $new_name);
+
+Rename an owner.
+
+Nothing happens if the file does not have an owner with the old name.
+
=head2 rename_project
$codeowners->rename_project($old_name => $new_name);
use File::Codeowners;
use Test::Builder;
-our $VERSION = '0.48'; # VERSION
+our $VERSION = '0.49'; # VERSION
my $Test = Test::Builder->new;
=head1 VERSION
-version 0.48
+version 0.49
=head1 SYNOPSIS