Bug#852332: dh-make-perl: DEBFULLNAME and DEBEMAIL should be used with git

2017-01-25 Thread gregor herrmann
On Tue, 24 Jan 2017 15:59:04 +, Carnë Draug wrote:

> In the mean time, I have noticed that the commits done automatically
> by pristine-tar also need consideration.  Since pristine-tar does not
> provide an option to set author, I used %ENV variables in that case.
> I have attached a new patch.

Thanks!
I've merged and pushed your commit now.
 

Cheers,
gregor

-- 
 .''`.  https://info.comodo.priv.at/ - Debian Developer https://www.debian.org
 : :' : OpenPGP fingerprint D1E1 316E 93A7 60A8 104D  85FA BB3A 6801 8649 AA06
 `. `'  Member of VIBE!AT & SPI, fellow of the Free Software Foundation Europe
   `-   NP: Leonard Cohen: First we take Manhatten


signature.asc
Description: Digital Signature


Bug#852332: dh-make-perl: DEBFULLNAME and DEBEMAIL should be used with git

2017-01-24 Thread Carnë Draug
On 24 January 2017 at 14:19, Carnë Draug  wrote:
> Package: dh-make-perl
> Version: 0.92
> Followup-For: Bug #852332
>
> On 24 January 2017 at 13:15, gregor herrmann  wrote:
>> On Tue, 24 Jan 2017 12:55:10 +, Dominic Hargreaves wrote:
>>
>>> > @@ -777,7 +777,7 @@ sub git_add_debian {
>>> >
>>> >  my $git = Git->repository( $self->main_dir );
>>> >  $git->command( 'add', 'debian' );
>>> > -$git->command( 'commit', '-m',
>>> > +$git->command( 'commit', '--author', $self->get_developer, '-m',
>>> >  "Initial packaging by dh-make-perl $VERSION" );
>>> >  $git->command(
>>> >  qw( remote add origin ),
>>>
>>> This will indeed create commits with the email and name specified, but
>>> the committer address will not be overridden which is probably confusing.
>>
>> Ack.
>> Maybe setting GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL via
>> environment variables would work?
>
> There are options to git, not to git commit.  One can use:
>
> git commit -c "user.name=Foo" -c "user.email=Bar" ...
>
> Which would mean changing DhMakePerl::Command::Packaging to have
> get_email and get_name (which would then also be used by
> get_developer).  I have attached a new patch that does that.
>

That should have been:

git -c "user.name=Foo" -c "user.email=Bar" commit ...

In the mean time, I have noticed that the commits done automatically
by pristine-tar also need consideration.  Since pristine-tar does not
provide an option to set author, I used %ENV variables in that case.
I have attached a new patch.

Carnë
From 1a477bd83d2d6137c2f184bafd4aa759b64feef5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carn=C3=AB=20Draug?= 
Date: Tue, 24 Jan 2017 15:50:02 +
Subject: [PATCH] DhMakePerl::Command::make: use author and email information
 for git commits.

DhMakePerl::Command::make (git_import_upstream__init_debian): use
email and author from dh-make-perl on git commits.
(git_add_debian): idem, but also define the required variables when
calling pristine-tar because pristine-tar does not have options to
support it.

DhMakePerl::Command::Packaging (get_name, get_email): two new methods
to retrieve only email and name because git handles them separate.

Closes: #852332
---
 Changes |  6 ++
 lib/DhMakePerl/Command/Packaging.pm | 36 +++-
 lib/DhMakePerl/Command/make.pm  | 22 +-
 3 files changed, 46 insertions(+), 18 deletions(-)

diff --git a/Changes b/Changes
index 9c47553..590adeb 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,10 @@
 0.93 (201x-xx-xx)
+  [ Carnë Draug ]
+  * Use dh-make-perl email and name information for git commits,
+including git commits done by pristine-tar.
+(Closes: #852332)
+  * DhMakePerl::Command::Packaging: add two new methods: get_email
+and get_name.
 
 0.92 (2016-09-20)
 
diff --git a/lib/DhMakePerl/Command/Packaging.pm b/lib/DhMakePerl/Command/Packaging.pm
index d759b66..e560abd 100644
--- a/lib/DhMakePerl/Command/Packaging.pm
+++ b/lib/DhMakePerl/Command/Packaging.pm
@@ -119,14 +119,27 @@ sub makefile_pl {
 return $self->main_file('Makefile.PL');
 }
 
-sub get_developer {
+sub get_email {
 my $self = shift;
-
 my $email = $self->cfg->email;
 
-my ( $user, $pwnam, $name, $mailh );
-$user = $ENV{LOGNAME} || $ENV{USER};
-$pwnam = getpwuid($<);
+$email ||= ( $ENV{DEBEMAIL} || $ENV{EMAIL} );
+unless ($email) {
+	my $mailh;
+chomp( $mailh = `cat /etc/mailname` );
+$email = $self->get_user . '@' . $mailh;
+}
+
+$email =~ s/^(.*)\s+<(.*)>$/$2/;
+return $email;
+}
+
+sub get_name {
+my $self = shift;
+
+my $name;
+my $user = $ENV{LOGNAME} || $ENV{USER};
+my $pwnam = getpwuid($<);
 die "Cannot determine current user\n" unless $pwnam;
 if ( defined $ENV{DEBFULLNAME} ) {
 $name = $ENV{DEBFULLNAME};
@@ -137,15 +150,12 @@ sub get_developer {
 }
 $user ||= $pwnam->name;
 $name ||= $user;
-$email ||= ( $ENV{DEBEMAIL} || $ENV{EMAIL} );
-unless ($email) {
-chomp( $mailh = `cat /etc/mailname` );
-$email = $user . '@' . $mailh;
-}
-
-$email =~ s/^(.*)\s+<(.*)>$/$2/;
+return $name;
+}
 
-return "$name <$email>";
+sub get_developer {
+my $self = shift;
+return $self->get_name . " <" . $self->get_email . ">";
 }
 
 sub fill_maintainer {
diff --git a/lib/DhMakePerl/Command/make.pm b/lib/DhMakePerl/Command/make.pm
index 31db889..8cbfd8e 100644
--- a/lib/DhMakePerl/Command/make.pm
+++ b/lib/DhMakePerl/Command/make.pm
@@ -744,11 +744,13 @@ sub git_import_upstream__init_debian {
 $self->reset_git_environment();
 
 Git::command( 'init', $self->main_dir );
+my @git_config = ( '-c', 'user.name=' . $self->get_name,
+   '-c', 'user.email=' . $self->get_email);
 
 my $git = Git->repository( $self->main_dir );
 $git->command( qw(symbolic-ref HEAD refs/heads/upstream) );
 $git->command( 'add', '.' );
-$g

Bug#852332: dh-make-perl: DEBFULLNAME and DEBEMAIL should be used with git

2017-01-24 Thread Carnë Draug
Package: dh-make-perl
Version: 0.92
Followup-For: Bug #852332

On 24 January 2017 at 13:15, gregor herrmann  wrote:
> On Tue, 24 Jan 2017 12:55:10 +, Dominic Hargreaves wrote:
>
>> > @@ -777,7 +777,7 @@ sub git_add_debian {
>> >
>> >  my $git = Git->repository( $self->main_dir );
>> >  $git->command( 'add', 'debian' );
>> > -$git->command( 'commit', '-m',
>> > +$git->command( 'commit', '--author', $self->get_developer, '-m',
>> >  "Initial packaging by dh-make-perl $VERSION" );
>> >  $git->command(
>> >  qw( remote add origin ),
>>
>> This will indeed create commits with the email and name specified, but
>> the committer address will not be overridden which is probably confusing.
>
> Ack.
> Maybe setting GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL via
> environment variables would work?

There are options to git, not to git commit.  One can use:

git commit -c "user.name=Foo" -c "user.email=Bar" ...

Which would mean changing DhMakePerl::Command::Packaging to have
get_email and get_name (which would then also be used by
get_developer).  I have attached a new patch that does that.

Carnë
From 941e701f86cb754594789aa5231416f4eb8a3a61 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carn=C3=AB=20Draug?= 
Date: Tue, 24 Jan 2017 14:15:15 +
Subject: [PATCH] DhMakePerl::Command::make: use author and email information
 for git commits.

DhMakePerl::Command::Packaging (get_name, get_email): two new methods
to retrieve only email and name because git handles them separate.

Closes: #852332
---
 Changes |  5 +
 lib/DhMakePerl/Command/Packaging.pm | 36 +++-
 lib/DhMakePerl/Command/make.pm  | 10 +++---
 3 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/Changes b/Changes
index 9c47553..4c952ec 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,9 @@
 0.93 (201x-xx-xx)
+  [ Carnë Draug ]
+  * Use dh-make-perl email and name information for git commits.
+(Closes: #852332)
+  * DhMakePerl::Command::Packaging: add two new methods: get_email
+and get_name.
 
 0.92 (2016-09-20)
 
diff --git a/lib/DhMakePerl/Command/Packaging.pm 
b/lib/DhMakePerl/Command/Packaging.pm
index d759b66..e560abd 100644
--- a/lib/DhMakePerl/Command/Packaging.pm
+++ b/lib/DhMakePerl/Command/Packaging.pm
@@ -119,14 +119,27 @@ sub makefile_pl {
 return $self->main_file('Makefile.PL');
 }
 
-sub get_developer {
+sub get_email {
 my $self = shift;
-
 my $email = $self->cfg->email;
 
-my ( $user, $pwnam, $name, $mailh );
-$user = $ENV{LOGNAME} || $ENV{USER};
-$pwnam = getpwuid($<);
+$email ||= ( $ENV{DEBEMAIL} || $ENV{EMAIL} );
+unless ($email) {
+   my $mailh;
+chomp( $mailh = `cat /etc/mailname` );
+$email = $self->get_user . '@' . $mailh;
+}
+
+$email =~ s/^(.*)\s+<(.*)>$/$2/;
+return $email;
+}
+
+sub get_name {
+my $self = shift;
+
+my $name;
+my $user = $ENV{LOGNAME} || $ENV{USER};
+my $pwnam = getpwuid($<);
 die "Cannot determine current user\n" unless $pwnam;
 if ( defined $ENV{DEBFULLNAME} ) {
 $name = $ENV{DEBFULLNAME};
@@ -137,15 +150,12 @@ sub get_developer {
 }
 $user ||= $pwnam->name;
 $name ||= $user;
-$email ||= ( $ENV{DEBEMAIL} || $ENV{EMAIL} );
-unless ($email) {
-chomp( $mailh = `cat /etc/mailname` );
-$email = $user . '@' . $mailh;
-}
-
-$email =~ s/^(.*)\s+<(.*)>$/$2/;
+return $name;
+}
 
-return "$name <$email>";
+sub get_developer {
+my $self = shift;
+return $self->get_name . " <" . $self->get_email . ">";
 }
 
 sub fill_maintainer {
diff --git a/lib/DhMakePerl/Command/make.pm b/lib/DhMakePerl/Command/make.pm
index 31db889..dae325b 100644
--- a/lib/DhMakePerl/Command/make.pm
+++ b/lib/DhMakePerl/Command/make.pm
@@ -744,11 +744,13 @@ sub git_import_upstream__init_debian {
 $self->reset_git_environment();
 
 Git::command( 'init', $self->main_dir );
+my @git_config = ( '-c', 'user.name="' . $self->get_name . '"',
+   '-c', 'user.email="' . $self->get_email . '"');
 
 my $git = Git->repository( $self->main_dir );
 $git->command( qw(symbolic-ref HEAD refs/heads/upstream) );
 $git->command( 'add', '.' );
-$git->command( 'commit', '-m',
+$git->command( 'commit', @git_config, '-m',
   "Import original source of "
 . $self->perlname . ' '
 . $self->version );
@@ -762,7 +764,7 @@ sub git_import_upstream__init_debian {
   # debian/ directory from the working tree; git has the history, so I 
don't
   # need the debian.bak
   $git->command( 'rm', '-r', $self->debian_dir );
-  $git->command( 'commit', '-m',
+  $git->command( 'commit', @git_config, '-m',
  'Removed debian directory embedded in upstream source' );
 }
 }
@@ -776,8 +778,10 @@ sub git_add_debian {
 $self->reset_git_environment;
 
 my $git = Git->repository( $self->main

Bug#852332: dh-make-perl: DEBFULLNAME and DEBEMAIL should be used with git

2017-01-24 Thread gregor herrmann
On Tue, 24 Jan 2017 12:55:10 +, Dominic Hargreaves wrote:

> > @@ -777,7 +777,7 @@ sub git_add_debian {
> >  
> >  my $git = Git->repository( $self->main_dir );
> >  $git->command( 'add', 'debian' );
> > -$git->command( 'commit', '-m',
> > +$git->command( 'commit', '--author', $self->get_developer, '-m',
> >  "Initial packaging by dh-make-perl $VERSION" );
> >  $git->command(
> >  qw( remote add origin ),
> 
> This will indeed create commits with the email and name specified, but
> the committer address will not be overridden which is probably confusing.

Ack.
Maybe setting GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL via
environment variables would work?

> I think I'm leaning towards adding the repo config being the least
> worst option, but I'm not completely sure.

Hm. I'm not convinced ... I tend to think it's the individual's
responsibility to set the git variables for manual git commits, as
usual (using DEBFULLNAME and DEBEMAIL for intial creation of the repo
sounds ok to me, as this happens during package creation and it might
not be completely obvious that this involves automated git commits).


Cheers,
gregor

-- 
 .''`.  https://info.comodo.priv.at/ - Debian Developer https://www.debian.org
 : :' : OpenPGP fingerprint D1E1 316E 93A7 60A8 104D  85FA BB3A 6801 8649 AA06
 `. `'  Member of VIBE!AT & SPI, fellow of the Free Software Foundation Europe
   `-   BOFH excuse #283:  Lawn mower blade in your fan need sharpening 



Bug#852332: dh-make-perl: DEBFULLNAME and DEBEMAIL should be used with git

2017-01-24 Thread Dominic Hargreaves
On Tue, Jan 24, 2017 at 12:32:58PM +, Carnë Draug wrote:

> diff --git a/lib/DhMakePerl/Command/make.pm b/lib/DhMakePerl/Command/make.pm
> index 31db889..4cde1da 100644
> --- a/lib/DhMakePerl/Command/make.pm
> +++ b/lib/DhMakePerl/Command/make.pm
> @@ -748,7 +748,7 @@ sub git_import_upstream__init_debian {
>  my $git = Git->repository( $self->main_dir );
>  $git->command( qw(symbolic-ref HEAD refs/heads/upstream) );
>  $git->command( 'add', '.' );
> -$git->command( 'commit', '-m',
> +$git->command( 'commit', '--author', $self->get_developer, '-m',
>"Import original source of "
>  . $self->perlname . ' '
>  . $self->version );
> @@ -762,7 +762,7 @@ sub git_import_upstream__init_debian {
># debian/ directory from the working tree; git has the history, so I 
> don't
># need the debian.bak
>$git->command( 'rm', '-r', $self->debian_dir );
> -  $git->command( 'commit', '-m',
> +  $git->command( 'commit', '--author', $self->get_developer, '-m',
>   'Removed debian directory embedded in upstream source' 
> );
>  }
>  }
> @@ -777,7 +777,7 @@ sub git_add_debian {
>  
>  my $git = Git->repository( $self->main_dir );
>  $git->command( 'add', 'debian' );
> -$git->command( 'commit', '-m',
> +$git->command( 'commit', '--author', $self->get_developer, '-m',
>  "Initial packaging by dh-make-perl $VERSION" );
>  $git->command(
>  qw( remote add origin ),

This will indeed create commits with the email and name specified, but
the committer address will not be overridden which is probably confusing.
Also, any future commits to the repo it created will use the global default,
which may be confusing. (There's no option to override the committer
in the git commit command)

Setting the per-repo config would fix both these issues at the expense
of sprinkling potentially unwanted hard-coded data in the repos. Changing
the git global default would obviously be unwanted and rude.

I think I'm leaning towards adding the repo config being the least
worst option, but I'm not completely sure.

Dominic.



Bug#852332: dh-make-perl: DEBFULLNAME and DEBEMAIL should be used with git

2017-01-24 Thread Carnë Draug
Package: dh-make-perl
Version: 0.92
Followup-For: Bug #852332

I have attached a git patch that fixes the issue.

-- System Information:
Debian Release: 9.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 4.8.0-2-amd64 (SMP w/32 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages dh-make-perl depends on:
ii  debhelper  10.2.3
ii  dpkg-dev   1.18.18
ii  fakeroot   1.21-3
ii  libapt-pkg-perl0.1.30
ii  libarray-unique-perl   0.08-2
ii  libclass-accessor-perl 0.34-1
ii  libconfig-ini-perl 1:0.025-1
ii  libdebian-source-perl  0.92
ii  libdpkg-perl   1.18.18
ii  libemail-address-perl  1.908-1
ii  libemail-date-format-perl  1.005-1
ii  libfile-which-perl 1.21-1
ii  liblist-moreutils-perl 0.416-1+b1
ii  libmodule-depends-perl 0.16-3
ii  libparse-debianchangelog-perl  1.2.0-12
ii  libsoftware-license-perl   0.103012-1
ii  libtie-ixhash-perl 1.23-2
ii  libwww-mechanize-perl  1.83-1
ii  libwww-perl6.15-1
ii  libyaml-libyaml-perl   0.63-2
ii  libyaml-perl   1.21-1
ii  make   4.1-9
ii  perl   5.24.1~rc4-1
ii  perl-modules-5.22 [libcpan-meta-perl]  5.22.2-1
ii  perl-modules-5.24 [libcpan-meta-perl]  5.24.1~rc4-1

Versions of packages dh-make-perl recommends:
ii  apt   1.4~beta3
ii  apt-file  3.1.3
ii  git   1:2.11.0-2
ii  libdpkg-parse-perl0.03-1
ii  libmodule-build-perl  0.422000-1
ii  pristine-tar  1.37

dh-make-perl suggests no packages.

-- no debconf information
From b8284e9dce8cfd31ee060c79ba8f2175eedf7212 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carn=C3=AB=20Draug?= 
Date: Tue, 24 Jan 2017 12:06:48 +
Subject: [PATCH] DhMakePerl::Command::make: use author and email information
 for git commits.

Closes: #852332
---
 Changes| 3 +++
 lib/DhMakePerl/Command/make.pm | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Changes b/Changes
index 9c47553..8c5e37f 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,7 @@
 0.93 (201x-xx-xx)
+  [ Carnë Draug ]
+  * Use dh-make-perl email and name information for git commits.
+(Closes: #852332)
 
 0.92 (2016-09-20)
 
diff --git a/lib/DhMakePerl/Command/make.pm b/lib/DhMakePerl/Command/make.pm
index 31db889..4cde1da 100644
--- a/lib/DhMakePerl/Command/make.pm
+++ b/lib/DhMakePerl/Command/make.pm
@@ -748,7 +748,7 @@ sub git_import_upstream__init_debian {
 my $git = Git->repository( $self->main_dir );
 $git->command( qw(symbolic-ref HEAD refs/heads/upstream) );
 $git->command( 'add', '.' );
-$git->command( 'commit', '-m',
+$git->command( 'commit', '--author', $self->get_developer, '-m',
   "Import original source of "
 . $self->perlname . ' '
 . $self->version );
@@ -762,7 +762,7 @@ sub git_import_upstream__init_debian {
   # debian/ directory from the working tree; git has the history, so I 
don't
   # need the debian.bak
   $git->command( 'rm', '-r', $self->debian_dir );
-  $git->command( 'commit', '-m',
+  $git->command( 'commit', '--author', $self->get_developer, '-m',
  'Removed debian directory embedded in upstream source' );
 }
 }
@@ -777,7 +777,7 @@ sub git_add_debian {
 
 my $git = Git->repository( $self->main_dir );
 $git->command( 'add', 'debian' );
-$git->command( 'commit', '-m',
+$git->command( 'commit', '--author', $self->get_developer, '-m',
 "Initial packaging by dh-make-perl $VERSION" );
 $git->command(
 qw( remote add origin ),
-- 
2.11.0



Bug#852332: dh-make-perl: DEBFULLNAME and DEBEMAIL should be used with git

2017-01-23 Thread Carnë Draug
Package: dh-make-perl
Version: 0.92
Severity: wishlist

dh-make-perl recognizes the DEBFULLNAME and DEBEMAIL environment
variables.  However, those are not used as author or email when making
git commits which then defaults to username and hostname.

Since dh-make-perl already recognizes variables that set that value,
it would make sense for them to also be used for the git commits.

-- System Information:
Debian Release: 9.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 4.8.0-2-amd64 (SMP w/32 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages dh-make-perl depends on:
ii  debhelper  10.2.3
ii  dpkg-dev   1.18.18
ii  fakeroot   1.21-3
ii  libapt-pkg-perl0.1.30
ii  libarray-unique-perl   0.08-2
ii  libclass-accessor-perl 0.34-1
ii  libconfig-ini-perl 1:0.025-1
ii  libdebian-source-perl  0.92
ii  libdpkg-perl   1.18.18
ii  libemail-address-perl  1.908-1
ii  libemail-date-format-perl  1.005-1
ii  libfile-which-perl 1.21-1
ii  liblist-moreutils-perl 0.416-1+b1
ii  libmodule-depends-perl 0.16-3
ii  libparse-debianchangelog-perl  1.2.0-12
ii  libsoftware-license-perl   0.103012-1
ii  libtie-ixhash-perl 1.23-2
ii  libwww-mechanize-perl  1.83-1
ii  libwww-perl6.15-1
ii  libyaml-libyaml-perl   0.63-2
ii  libyaml-perl   1.21-1
ii  make   4.1-9
ii  perl   5.24.1~rc4-1
ii  perl-modules-5.22 [libcpan-meta-perl]  5.22.2-1
ii  perl-modules-5.24 [libcpan-meta-perl]  5.24.1~rc4-1

Versions of packages dh-make-perl recommends:
ii  apt   1.4~beta3
ii  apt-file  3.1.3
ii  git   1:2.11.0-2
ii  libdpkg-parse-perl0.03-1
ii  libmodule-build-perl  0.422000-1
ii  pristine-tar  1.37

dh-make-perl suggests no packages.

-- no debconf information