morgan pushed to branch main at The Tor Project / Applications / RBM
Commits:
-
8c773150
by Nicolas Vigier at 2025-01-29T13:24:00+01:00
2 changed files:
Changes:
| ... | ... | @@ -191,7 +191,8 @@ fetch:: |
| 191 | 191 | from the remote git or hg repository should be fetched
|
| 192 | 192 | automatically. If the value is +if_needed+, the git or hg
|
| 193 | 193 | repository is fetched only if the selected commit cannot be
|
| 194 | - found in the local clone. The default is +if_needed+.
|
|
| 194 | + found in the local clone, or if +git_hash+ is not pointing to
|
|
| 195 | + a git tag or full hash. The default is +if_needed+.
|
|
| 195 | 196 | |
| 196 | 197 | ENV::
|
| 197 | 198 | This option, defined in the workspace config, is a hash
|
| ... | ... | @@ -424,8 +424,16 @@ sub git_need_fetch { |
| 424 | 424 | if ($fetch eq 'if_needed') {
|
| 425 | 425 | my $git_hash = project_config($project, 'git_hash', $options)
|
| 426 | 426 | || exit_error "No git_hash specified for project $project";
|
| 427 | - my (undef, undef, $success) = capture_exec('git', 'rev-parse',
|
|
| 427 | + my ($stdout, undef, $success) = capture_exec('git', 'rev-parse',
|
|
| 428 | 428 | '--verify', "$git_hash^{commit}");
|
| 429 | + return 1 unless $success;
|
|
| 430 | + # If rev-parse returns the same as git_hash, then git_hash is
|
|
| 431 | + # a hash and there is no need to fetch
|
|
| 432 | + return 0 if $stdout eq $git_hash;
|
|
| 433 | + # Check if git_hash is a tag. If it's not a tag or hash then
|
|
| 434 | + # it's probably a branch and we should do a fetch.
|
|
| 435 | + (undef, undef, $success) = capture_exec('git', 'rev-parse',
|
|
| 436 | + '--verify', "$git_hash^{tag}");
|
|
| 429 | 437 | return !$success;
|
| 430 | 438 | }
|
| 431 | 439 | return $fetch;
|