[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/rbm][main] Bug 40072: Move capture_exec to a separate module



Title: GitLab

boklm pushed to branch main at The Tor Project / Applications / RBM

Commits:

  • efd874ab
    by Nicolas Vigier at 2024-02-08T13:13:58+01:00
    Bug 40072: Move capture_exec to a separate module
    
    Because the RBM and RBM::DefaultConfig modules have circular dependencies,
    exporting functions from RBM to RBM::DefaultConfig doesn't work, which
    means that part of the changes for rbm#40068 didn't work. We could fix
    that by using `RBM::capture_exec` instead of `capture_exec`. An other
    solution is to make a separate module for `capture_exec`. Since the RBM
    modules is becoming big, I think it's a good idea to move independent
    parts to a separate modules.
    

3 changed files:

Changes:

  • lib/RBM.pm
    ... ... @@ -10,7 +10,6 @@ use YAML::XS qw(LoadFile);
    10 10
     use Template;
    
    11 11
     use File::Basename;
    
    12 12
     use IO::Handle;
    
    13
    -use Capture::Tiny qw(capture);
    
    14 13
     use File::Temp;
    
    15 14
     use File::Copy;
    
    16 15
     use File::Copy::Recursive qw(fcopy);
    
    ... ... @@ -18,6 +17,7 @@ use File::Path qw(make_path);
    18 17
     use File::Basename;
    
    19 18
     use String::ShellQuote;
    
    20 19
     use Sort::Versions;
    
    20
    +use RBM::CaptureExec qw(capture_exec);
    
    21 21
     use RBM::DefaultConfig;
    
    22 22
     use Digest::SHA qw(sha256_hex);
    
    23 23
     use Data::UUID;
    
    ... ... @@ -29,7 +29,7 @@ use feature "state";
    29 29
     BEGIN {
    
    30 30
         require Exporter;
    
    31 31
         our @ISA = qw(Exporter);
    
    32
    -    our @EXPORT = qw(exit_error capture_exec);
    
    32
    +    our @EXPORT = qw(exit_error);
    
    33 33
     }
    
    34 34
     
    
    35 35
     our $config;
    
    ... ... @@ -308,15 +308,6 @@ sub exit_error {
    308 308
         exit (exists $_[1] ? $_[1] : 1);
    
    309 309
     }
    
    310 310
     
    
    311
    -sub capture_exec {
    
    312
    -    my @cmd = @_;
    
    313
    -    my ($stdout, $stderr, $exit) = capture {
    
    314
    -        system(@cmd);
    
    315
    -    };
    
    316
    -    return ($stdout, $stderr, $exit == 0, $exit) if wantarray();
    
    317
    -    return $stdout;
    
    318
    -}
    
    319
    -
    
    320 311
     sub set_git_gpg_wrapper {
    
    321 312
         my ($project) = @_;
    
    322 313
         my $w = project_config($project, 'gpg_wrapper');
    

  • lib/RBM/CaptureExec.pm
    1
    +package RBM::CaptureExec;
    
    2
    +
    
    3
    +use Capture::Tiny qw(capture);
    
    4
    +
    
    5
    +BEGIN {
    
    6
    +    require Exporter;
    
    7
    +    our @ISA = qw(Exporter);
    
    8
    +    our @EXPORT = qw(capture_exec);
    
    9
    +    our @EXPORT_OK = qw(capture_exec);
    
    10
    +}
    
    11
    +
    
    12
    +sub capture_exec {
    
    13
    +    my @cmd = @_;
    
    14
    +    my ($stdout, $stderr, $exit) = capture {
    
    15
    +        system(@cmd);
    
    16
    +    };
    
    17
    +    return ($stdout, $stderr, $exit == 0, $exit) if wantarray();
    
    18
    +    return $stdout;
    
    19
    +}
    
    20
    +
    
    21
    +1;

  • lib/RBM/DefaultConfig.pm
    ... ... @@ -10,7 +10,8 @@ BEGIN {
    10 10
     }
    
    11 11
     
    
    12 12
     use File::Basename;
    
    13
    -use RBM qw(capture_exec);
    
    13
    +use RBM;
    
    14
    +use RBM::CaptureExec qw(capture_exec);
    
    14 15
     use Cwd qw(getcwd);
    
    15 16
     use File::Temp;
    
    16 17
     use File::Path qw(make_path);
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits