Re: [PATCH v2] Dpkg::Version, Dpkg::Source::Package: move version-without-epoch outputting to the Version module
On Sun, 2013-02-10 at 13:18:28 +0100, Bernhard R. Link wrote:
> how about this one?
Yes, better, thanks. :)
I've done some minor changes while I was resolving the conflicts with
my local tree.
> diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm
> index 47ea319..aff0eed 100644
> --- a/scripts/Dpkg/Source/Package.pm
> +++ b/scripts/Dpkg/Source/Package.pm
> @@ -289,11 +289,7 @@ sub get_basename {
> error(_g("source and version are required to compute the source basename"));
> }
> my $v = Dpkg::Version->new($f->{'Version'});
> - my $basename = $f->{'Source'} . "_" . $v->version();
> - if ($with_revision and $f->{'Version'} =~ /-/) {
> - $basename .= "-" . $v->revision();
> - }
> - return $basename;
> + return $f->{'Source'} . "_" . $v->as_string({no_epoch=>1, no_revision=>!$with_revision});
I've added spaces around the options arguments.
> diff --git a/scripts/Dpkg/Version.pm b/scripts/Dpkg/Version.pm
> index 7c1c0f6..19c4509 100644
> --- a/scripts/Dpkg/Version.pm
> +++ b/scripts/Dpkg/Version.pm
> @@ -177,18 +177,22 @@ sub comparison {
> return version_compare_part($a->revision(), $b->revision());
> }
>
> -=item "$v", $v->as_string()
> +=item "$v", $v->as_string(), $v->as_string({no_epoch=>1, no_revision=>1})
I've added a small mention about the new options here.
> Returns the string representation of the version number.
>
> =cut
>
> sub as_string {
> - my ($self) = @_;
> + my ($self, $arg_ref) = @_;
> + my $no_epoch = $arg_ref->{no_epoch} || '';
> + $no_epoch ||= $self->{no_epoch};
> + my $no_revision = $arg_ref->{no_revision} || '';
> + $no_revision ||= $self->{no_revision};
And replaced these with something like:
my $var = $opt // $def;
Thanks,
Guillem
Reply to: