diff options
| author | Nicolas Vigier <boklm@torproject.org> | 2020-02-12 11:16:22 +0100 |
|---|---|---|
| committer | Nicolas Vigier <boklm@torproject.org> | 2020-02-12 11:16:22 +0100 |
| commit | ce6b9136fc9e006536b34844946d67aa92cc0c21 (patch) | |
| tree | 34bbb51ff1454cb63f50845c662dbb7775cd97c6 | |
| parent | 94fce31e54d3fd491cdb3e3b9401919c0e841360 (diff) | |
Bug 33283: Add caching for the exec template function
| -rw-r--r-- | lib/RBM.pm | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -475,10 +475,14 @@ sub run_script { sub execute { my ($project, $cmd, $options) = @_; + CORE::state %cache; + my $res_name; my $old_cwd = getcwd; if (project_config($project, 'git_url', $options)) { my $git_hash = project_config($project, 'git_hash', $options) || exit_error "No git_hash specified for project $project"; + $res_name = "git-$git_hash-$cmd"; + return $cache{$res_name} if exists $cache{$res_name}; git_clone_fetch_chdir($project, $options); my ($stdout, $stderr, $success, $exit_code) = capture_exec('git', 'checkout', $git_hash); @@ -494,6 +498,8 @@ sub execute { } elsif (project_config($project, 'hg_url', $options)) { my $hg_hash = project_config($project, 'hg_hash', $options) || exit_error "No hg_hash specified for project $project"; + $res_name = "hg-$hg_hash-$cmd"; + return $cache{$res_name} if exists $cache{$res_name}; hg_clone_fetch_chdir($project, $options); my ($stdout, $stderr, $success, $exit_code) = capture_exec('hg', 'update', '-C', $hg_hash); @@ -503,7 +509,8 @@ sub execute { = run_script($project, $cmd, \&capture_exec); chdir($old_cwd); chomp $stdout; - return $success ? $stdout : undef; + $cache{$res_name} = $success ? $stdout : undef; + return $cache{$res_name}; } sub gpg_id { |
