boklm pushed to branch main at The Tor Project / Applications / RBM
Commits:
-
f18daa3f
by Nicolas Vigier at 2024-10-27T17:22:45+01:00
3 changed files:
Changes:
| ... | ... | @@ -107,9 +107,11 @@ exec:: |
| 107 | 107 | considered to be a script, which will be written to a temporary
|
| 108 | 108 | file and executed. The second argument of the exec function is
|
| 109 | 109 | an optional $options hash, used to override values of 'git_url',
|
| 110 | - 'hg_url', 'fetch', 'git_hash' or 'hg_hash'. If neither 'git_url'
|
|
| 111 | - nor 'hg_url' is set, the command is executed from the directory
|
|
| 112 | - where the 'rbm.conf' file is located.
|
|
| 110 | + 'hg_url', 'fetch', 'git_hash' or 'hg_hash'. Before running the
|
|
| 111 | + command a checkout of 'git_hash' or 'hg_hash' is done, unless
|
|
| 112 | + 'exec_noco' is set to true. If neither 'git_url' nor 'hg_url'
|
|
| 113 | + is set, the command is executed from the directory where the
|
|
| 114 | + 'rbm.conf' file is located.
|
|
| 113 | 115 | |
| 114 | 116 | path::
|
| 115 | 117 | A function to return an absolute path. It takes a path as first
|
| ... | ... | @@ -551,15 +551,18 @@ sub execute { |
| 551 | 551 | CORE::state %cache;
|
| 552 | 552 | my $res_name = '';
|
| 553 | 553 | my $old_cwd = getcwd;
|
| 554 | + my $exec_noco = ref $options eq 'HASH' && $options->{exec_noco};
|
|
| 554 | 555 | if (project_config($project, 'git_url', $options)) {
|
| 555 | 556 | my $git_hash = project_config($project, 'git_hash', $options)
|
| 556 | 557 | || exit_error "No git_hash specified for project $project";
|
| 557 | 558 | $res_name = "git-$project-/-$git_hash-/-$cmd";
|
| 558 | 559 | return $cache{$res_name} if exists $cache{$res_name};
|
| 559 | 560 | git_clone_fetch_chdir($project, $options);
|
| 560 | - my ($stdout, $stderr, $success, $exit_code)
|
|
| 561 | + if (!$exec_noco) {
|
|
| 562 | + my ($stdout, $stderr, $success, $exit_code)
|
|
| 561 | 563 | = capture_exec('git', 'checkout', $git_hash);
|
| 562 | - exit_error "Cannot checkout $git_hash:\n$stderr" unless $success;
|
|
| 564 | + exit_error "Cannot checkout $git_hash:\n$stderr" unless $success;
|
|
| 565 | + }
|
|
| 563 | 566 | git_submodule_init_sync_update()
|
| 564 | 567 | if project_config($project, 'git_submodule', $options);
|
| 565 | 568 | } elsif (project_config($project, 'hg_url', $options)) {
|
| ... | ... | @@ -568,9 +571,11 @@ sub execute { |
| 568 | 571 | $res_name = "hg-$project-/-$hg_hash-/-$cmd";
|
| 569 | 572 | return $cache{$res_name} if exists $cache{$res_name};
|
| 570 | 573 | hg_clone_fetch_chdir($project, $options);
|
| 571 | - my ($stdout, $stderr, $success, $exit_code)
|
|
| 574 | + if (!$exec_noco) {
|
|
| 575 | + my ($stdout, $stderr, $success, $exit_code)
|
|
| 572 | 576 | = capture_exec('hg', 'update', '-C', $hg_hash);
|
| 573 | - exit_error "Cannot checkout $hg_hash:\n$stderr" unless $success;
|
|
| 577 | + exit_error "Cannot checkout $hg_hash:\n$stderr" unless $success;
|
|
| 578 | + }
|
|
| 574 | 579 | } else {
|
| 575 | 580 | chdir($config->{basedir});
|
| 576 | 581 | }
|
| ... | ... | @@ -126,9 +126,9 @@ our %default_config = ( |
| 126 | 126 | abbrev_length => '12',
|
| 127 | 127 | abbrev => '[%
|
| 128 | 128 | IF c("git_url");
|
| 129 | - exec("git log -1 --abbrev=" _ c("abbrev_length") _ " --format=%h " _ c("git_hash"));
|
|
| 129 | + exec("git log -1 --abbrev=" _ c("abbrev_length") _ " --format=%h " _ c("git_hash"), { exec_noco => 1 });
|
|
| 130 | 130 | ELSE;
|
| 131 | - exec(c("hg") _ " id -i -r " _ c("hg_hash"));
|
|
| 131 | + exec(c("hg") _ " id -i -r " _ c("hg_hash"), { exec_noco => 1 });
|
|
| 132 | 132 | END;
|
| 133 | 133 | %]',
|
| 134 | 134 | timestamp => sub {
|
| ... | ... | @@ -136,12 +136,14 @@ our %default_config = ( |
| 136 | 136 | if (RBM::project_config($project, 'git_url', $options)) {
|
| 137 | 137 | my $git_hash = RBM::project_config($project, 'git_hash', $options);
|
| 138 | 138 | return RBM::execute($project,
|
| 139 | - "git show -s --format=format:%ct ${git_hash}^{commit}", $options);
|
|
| 139 | + "git show -s --format=format:%ct ${git_hash}^{commit}",
|
|
| 140 | + { %$options, exec_noco => 1 });
|
|
| 140 | 141 | } elsif (RBM::project_config($project, 'hg_url', $options)) {
|
| 141 | 142 | my $hg = RBM::project_config($project, 'hg', $options);
|
| 142 | 143 | my $hg_hash = RBM::project_config($project, 'hg_hash', $options);
|
| 143 | 144 | my $changeset = RBM::execute($project,
|
| 144 | - "$hg export --noninteractive -r $hg_hash", $options);
|
|
| 145 | + "$hg export --noninteractive -r $hg_hash",
|
|
| 146 | + { %$options, exec_noco => 1 });
|
|
| 145 | 147 | foreach my $line (split "\n", $changeset) {
|
| 146 | 148 | return $1 if ($line =~ m/^# Date (\d+) \d+/);
|
| 147 | 149 | }
|