[tor-commits] [builders/rbm] 02/02: Bug 40010: Add git_branch option

gitolite role git at cupani.torproject.org
Tue Sep 20 09:45:59 UTC 2022


This is an automated email from the git hooks/post-receive script.

boklm pushed a commit to branch main
in repository builders/rbm.

commit 8ed3aa1c0b65c711947df2f0d483215510514253
Author: Jeremy Rand <jeremyrand at danwin1210.de>
AuthorDate: Sat May 7 21:05:47 2022 +0000

    Bug 40010: Add git_branch option
---
 doc/options_tar.asc |  6 ++++++
 lib/RBM.pm          | 15 +++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/doc/options_tar.asc b/doc/options_tar.asc
index 40e2cc5..898b47c 100644
--- a/doc/options_tar.asc
+++ b/doc/options_tar.asc
@@ -25,6 +25,12 @@ git_depth::
         depth, to decrease network and storage usage.  If not set,
         shallow clone/fetch is disabled.
 
+git_branch::
+        A Git ref name that will be exclusively cloned/fetched, to
+        decrease network and storage usage.  Must be a descendent
+        (inclusive) of git_hash.  If not set, all Git refs are
+        cloned/fetched.
+
 compress_tar::
         If set, the tarball created will be compressed in the select
         format. Possible values: xz, gz, bz2. The default is gz but it
diff --git a/lib/RBM.pm b/lib/RBM.pm
index fc9a7a1..d8e7b13 100644
--- a/lib/RBM.pm
+++ b/lib/RBM.pm
@@ -447,6 +447,11 @@ sub git_clone_fetch_chdir {
         push @clone_opts, ("--depth=$git_depth");
         push @fetch_opts, ("--depth=$git_depth");
     }
+    my @fetch_refs = ('+refs/heads/*:refs/heads/*', '+refs/tags/*:refs/tags/*');
+    if (my $git_branch = project_config($project, 'git_branch', $options)) {
+        push @clone_opts, ('--branch', $git_branch, '--single-branch');
+        @fetch_refs = ($git_branch);
+    }
     if (!chdir rbm_path("$clonedir/$project")) {
         chdir $clonedir || exit_error "Can't enter directory $clonedir: $!";
         if (system('git', 'clone', @clone_opts, $git_url, $project) != 0) {
@@ -462,12 +467,10 @@ sub git_clone_fetch_chdir {
             system('git', 'checkout', '-q', '--detach') == 0
                 || exit_error "Error running git checkout --detach";
         }
-        system('git', 'fetch', @fetch_opts, 'origin',
-                                '+refs/heads/*:refs/heads/*') == 0
-                || exit_error "Error fetching git repository";
-        system('git', 'fetch', @fetch_opts, 'origin',
-                                '+refs/tags/*:refs/tags/*') == 0
-                || exit_error "Error fetching git repository";
+        for my $fetch_ref (@fetch_refs) {
+            system('git', 'fetch', @fetch_opts, 'origin', $fetch_ref) == 0
+                || exit_error "Error fetching $fetch_ref from git repository $git_url";
+        }
         $config->{_rbm}{fetched_projects}{$project} = 1;
     }
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list