On 24 January 2017 at 14:19, Carnë Draug <carandraug+...@gmail.com> wrote: > Package: dh-make-perl > Version: 0.92 > Followup-For: Bug #852332 > > On 24 January 2017 at 13:15, gregor herrmann <gre...@debian.org> wrote: >> On Tue, 24 Jan 2017 12:55:10 +0000, 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?= <carandraug+...@gmail.com> Date: Tue, 24 Jan 2017 15:50:02 +0000 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', '.' ); - $git->command( 'commit', '-m', + $git->command( @git_config, 'commit', '-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( @git_config, 'commit', '-m', 'Removed debian directory embedded in upstream source' ); } } @@ -776,8 +778,12 @@ sub git_add_debian { $self->reset_git_environment; my $git = Git->repository( $self->main_dir ); + my $name = $self->get_name; + my $email = $self->get_email; + my @git_config = ( '-c', "user.name=$name", + '-c', "user.email=$email"); $git->command( 'add', 'debian' ); - $git->command( 'commit', '-m', + $git->command( @git_config, 'commit', '-m', "Initial packaging by dh-make-perl $VERSION" ); $git->command( qw( remote add origin ), @@ -788,8 +794,14 @@ sub git_add_debian { if ( File::Which::which('pristine-tar') ) { if ( $tarball and -f $tarball ) { $ENV{GIT_DIR} = File::Spec->catdir( $self->main_dir, '.git' ); - system( 'pristine-tar', 'commit', $tarball, "upstream/".$self->version ) >= 0 - or warn "error running pristine-tar: $!\n"; + my %backup_ENV = %ENV; + $ENV{GIT_COMMITTER_NAME} = $name; + $ENV{GIT_COMMITTER_EMAIL} = $email; + $ENV{GIT_AUTHOR_NAME} = $name; + $ENV{GIT_AUTHOR_EMAIL} = $email; + my $status = system( 'pristine-tar', 'commit', $tarball, "upstream/".$self->version ); + %ENV = %backup_ENV; + warn "error running pristine-tar: $!\n" if $status < 0; } else { die "No tarball found to handle with pristine-tar. Bailing out." -- 2.11.0