This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=6394ba430ab7f239c37bb5d39a24083860fffee3 commit 6394ba430ab7f239c37bb5d39a24083860fffee3 Author: Guillem Jover <[email protected]> AuthorDate: Sat Mar 18 19:53:12 2023 +0100 dpkg-genchanges: Refactor .changes file description formatting into a function This encapsulates the formatting into a function for more clear code on the call site. Changelog: internal --- scripts/dpkg-genchanges.pl | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index 54413dbd6..e1a8d856b 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -130,6 +130,20 @@ sub usage { "), $Dpkg::PROGNAME; } +sub format_desc +{ + my ($pkgname, $pkgtype, $desc) = @_; + + # XXX: This does not correctly truncate characters based on their width, + # but on the number of characters which will not work for wide ones. But + # we do not have anything better in perl core. + my $line = encode_utf8(sprintf('%-10s - %-.65s', $pkgname, + decode_utf8($desc))); + $line .= " ($pkgtype)" if $pkgtype ne 'deb'; + + return $line; +} + while (@ARGV) { $_ = shift @ARGV; @@ -387,9 +401,7 @@ foreach my $pkg ($control->get_packages()) { # Add description of all binary packages $d = $substvars->substvars($d); - my $desc = encode_utf8(sprintf('%-10s - %-.65s', $p, decode_utf8($d))); - $desc .= " ($pkg_type)" if $pkg_type ne 'deb'; - push @descriptions, $desc; + push @descriptions, format_desc($p, $pkg_type, $d); # List of files for this binary package. my @files = @{$pkg2file{$p}}; -- Dpkg.Org's dpkg

