[Bps-public-commit] GnuPG-Interface branch, master, updated. 0.52-58-gaab1611

? sunnavy sunnavy at bestpractical.com
Fri Jan 15 18:11:44 EST 2021


The branch, master has been updated
       via  aab1611ab93b436fc22b6763e3b4a6fdce7a622d (commit)
       via  0d2e942c136a2b6cdd9af549d412a667f02c6fa1 (commit)
      from  dce1ca59bff8ebd643b6a7d17db1b1b5948f200c (commit)

Summary of changes:
 MANIFEST               |  3 +++
 lib/GnuPG/Interface.pm | 24 +++++++++++++++++-------
 t/Interface.t          |  4 ++--
 t/version_updates.t    | 30 ++++++++++++++++++++++++++++++
 test/fake-gpg-v1       |  2 ++
 test/fake-gpg-v2       |  2 ++
 6 files changed, 56 insertions(+), 9 deletions(-)
 create mode 100644 t/version_updates.t
 create mode 100755 test/fake-gpg-v1
 create mode 100755 test/fake-gpg-v2

- Log -----------------------------------------------------------------
commit 0d2e942c136a2b6cdd9af549d412a667f02c6fa1
Author: Dianne Skoll <dianne at bestpractical.com>
Date:   Tue Aug 11 11:01:30 2020 -0400

    Make $gnupg->call('foo') update the internal GnuPG version number.
    
    Before, if you set the GPG executable using call(), and the
    version was different from the version used in the constructor,
    GnuPG::Interface would pass the wrong options to the program.
    
    This patch makes sure the executable and the version number
    are always in sync.

diff --git a/MANIFEST b/MANIFEST
index 7c04bb9..8b9c4a4 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -50,10 +50,13 @@ t/sign.t
 t/sign_and_encrypt.t
 t/UserId.t
 t/verify.t
+t/version_updates.t
 t/wrap_call.t
 t/zzz_cleanup.t
 test/encrypted.1.gpg
 test/encrypted.2.gpg
+test/fake-gpg-v1
+test/fake-gpg-v2
 test/fake-pinentry.pl
 test/gpg.conf
 test/key.1.asc
diff --git a/lib/GnuPG/Interface.pm b/lib/GnuPG/Interface.pm
index b11e4d2..c265443 100644
--- a/lib/GnuPG/Interface.pm
+++ b/lib/GnuPG/Interface.pm
@@ -30,11 +30,18 @@ use GnuPG::Handles;
 
 $VERSION = '1.00';
 
-has $_ => (
+has passphrase => (
     isa     => 'Any',
     is      => 'rw',
-    clearer => 'clear_' . $_,
-) for qw(call passphrase);
+    clearer => 'clear_passphrase',
+);
+
+has call => (
+    isa     => 'Any',
+    is      => 'rw',
+    trigger => 1,
+    clearer => 'clear_call',
+);
 
 # NB: GnuPG versions
 #
@@ -68,10 +75,7 @@ sub gnupg_call { shift->call(@_); }
 
 sub BUILD {
     my ( $self, $args ) = @_;
-
-    $self->hash_init( call => 'gpg' );
-    $self->hash_init(%$args);
-    $self->_set_version($self->_version());
+    $self->hash_init( call => 'gpg', %$args );
 }
 
 struct(
@@ -82,6 +86,12 @@ struct(
     }
 );
 
+# Update version if "call" is updated
+sub _trigger_call {
+    my ( $self, $gpg ) = @_;
+    $self->_set_version( $self->_version() );
+}
+
 #################################################################
 # real worker functions
 
diff --git a/t/Interface.t b/t/Interface.t
index 6d97956..ec5dfe5 100644
--- a/t/Interface.t
+++ b/t/Interface.t
@@ -10,8 +10,8 @@ use MyTest;
 
 use GnuPG::Interface;
 
-my $v1 = 'gpg';
-my $v2 = 'gnupg';
+my $v1 = './test/fake-gpg-v1';
+my $v2 = './test/fake-gpg-v2';
 
 my $gnupg = GnuPG::Interface->new( call => $v1 );
 
diff --git a/t/version_updates.t b/t/version_updates.t
new file mode 100644
index 0000000..758ee7b
--- /dev/null
+++ b/t/version_updates.t
@@ -0,0 +1,30 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use lib './t';
+use MyTest;
+use MyTestSpecific;
+
+TEST
+{
+    my $gpg = GnuPG::Interface->new(call => './test/fake-gpg-v1');
+    return ($gpg->version() eq '1.4.23');
+};
+
+
+TEST
+{
+    my $gpg = GnuPG::Interface->new(call => './test/fake-gpg-v2');
+    return ($gpg->version() eq '2.2.12');
+};
+
+TEST
+{
+    my $gpg = GnuPG::Interface->new(call => './test/fake-gpg-v1');
+    my $v1 = $gpg->version();
+    $gpg->call('./test/fake-gpg-v2');
+    my $v2 = $gpg->version();
+
+    return ($v1 eq '1.4.23' && $v2 eq '2.2.12');
+}
diff --git a/test/fake-gpg-v1 b/test/fake-gpg-v1
new file mode 100755
index 0000000..0a2a68f
--- /dev/null
+++ b/test/fake-gpg-v1
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo 'gpg (GnuPG) 1.4.23'
diff --git a/test/fake-gpg-v2 b/test/fake-gpg-v2
new file mode 100755
index 0000000..2578a44
--- /dev/null
+++ b/test/fake-gpg-v2
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo 'gpg (GnuPG) 2.2.12'

commit aab1611ab93b436fc22b6763e3b4a6fdce7a622d
Merge: dce1ca5 0d2e942
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Jan 16 07:11:24 2021 +0800

    Merge branch 'update-version-if-call-is-updated'


-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list