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


Commits:
8c773150 by Nicolas Vigier at 2025-01-29T13:24:00+01:00
Bug 40079: make `fetch: if_needed` fetch existing branches

Currently, `fetch: if_needed` will avoid doing a fetch if `git_hash` can
be resolved to a valid git revision. If `git_hash` is a hash or a tag,
there is no need to do a fetch, since those are not supposed to be
changing after a fetch. However, a branch is expected to change, so
doing a fetch in this case is useful.

- - - - -


2 changed files:

- doc/rbm_config.asc
- lib/RBM.pm


Changes:

=====================================
doc/rbm_config.asc
=====================================
@@ -191,7 +191,8 @@ fetch::
         from the remote git or hg repository should be fetched
         automatically. If the value is +if_needed+, the git or hg
         repository is fetched only if the selected commit cannot be
-        found in the local clone. The default is +if_needed+.
+        found in the local clone, or if +git_hash+ is not pointing to
+        a git tag or full hash. The default is +if_needed+.
 
 ENV::
         This option, defined in the workspace config, is a hash


=====================================
lib/RBM.pm
=====================================
@@ -424,8 +424,16 @@ sub git_need_fetch {
     if ($fetch eq 'if_needed') {
         my $git_hash = project_config($project, 'git_hash', $options)
                 || exit_error "No git_hash specified for project $project";
-        my (undef, undef, $success) = capture_exec('git', 'rev-parse',
+        my ($stdout, undef, $success) = capture_exec('git', 'rev-parse',
                                         '--verify', "$git_hash^{commit}");
+        return 1 unless $success;
+        # If rev-parse returns the same as git_hash, then git_hash is
+        # a hash and there is no need to fetch
+        return 0 if $stdout eq $git_hash;
+        # Check if git_hash is a tag. If it's not a tag or hash then
+        # it's probably a branch and we should do a fetch.
+        (undef, undef, $success) = capture_exec('git', 'rev-parse',
+                                        '--verify', "$git_hash^{tag}");
         return !$success;
     }
     return $fetch;



View it on GitLab: 
https://gitlab.torproject.org/tpo/applications/rbm/-/commit/8c773150bc10133f3903841c233458dc07456d2e

-- 
View it on GitLab: 
https://gitlab.torproject.org/tpo/applications/rbm/-/commit/8c773150bc10133f3903841c233458dc07456d2e
You're receiving this email because of your account on gitlab.torproject.org.


_______________________________________________
tbb-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to