[tor-commits] [builders/rbm] 01/02: Bug 40009: Add git_depth option

gitolite role git at cupani.torproject.org
Tue Sep 20 09:45:58 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 e7b453d37a4202ef1d0e41703d3595a4674eeb8d
Author: Jeremy Rand <jeremyrand at danwin1210.de>
AuthorDate: Sat May 7 20:46:13 2022 +0000

    Bug 40009: Add git_depth option
---
 doc/options_tar.asc |  5 +++++
 lib/RBM.pm          | 18 +++++++++++-------
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/doc/options_tar.asc b/doc/options_tar.asc
index c21317f..40e2cc5 100644
--- a/doc/options_tar.asc
+++ b/doc/options_tar.asc
@@ -20,6 +20,11 @@ git_submodule::
         If this option is enabled, git submodules are fetched and
         included in the tarball. This option is disabled by default.
 
+git_depth::
+        An integer specifying a depth for shallow Git clone/fetch
+        depth, to decrease network and storage usage.  If not set,
+        shallow clone/fetch is disabled.
+
 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 a92a04b..fc9a7a1 100644
--- a/lib/RBM.pm
+++ b/lib/RBM.pm
@@ -437,15 +437,19 @@ sub git_clone_fetch_chdir {
                                 'git_clone_dir', $options)));
     my $git_url = project_config($project, 'git_url', $options)
                 || exit_error "git_url is undefined";
-    my @clone_submod = ();
-    my @fetch_submod = ();
+    my @clone_opts = ();
+    my @fetch_opts = ();
     if (project_config($project, 'git_submodule', $options)) {
-        @clone_submod = ('--recurse-submodules');
-        @fetch_submod = ('--recurse-submodules=on-demand');
+        push @clone_opts, ('--recurse-submodules');
+        push @fetch_opts, ('--recurse-submodules=on-demand');
+    }
+    if (my $git_depth = project_config($project, 'git_depth', $options)) {
+        push @clone_opts, ("--depth=$git_depth");
+        push @fetch_opts, ("--depth=$git_depth");
     }
     if (!chdir rbm_path("$clonedir/$project")) {
         chdir $clonedir || exit_error "Can't enter directory $clonedir: $!";
-        if (system('git', 'clone', @clone_submod, $git_url, $project) != 0) {
+        if (system('git', 'clone', @clone_opts, $git_url, $project) != 0) {
             exit_error "Error cloning $git_url";
         }
         chdir($project) || exit_error "Error entering $project directory";
@@ -458,10 +462,10 @@ sub git_clone_fetch_chdir {
             system('git', 'checkout', '-q', '--detach') == 0
                 || exit_error "Error running git checkout --detach";
         }
-        system('git', 'fetch', @fetch_submod, 'origin',
+        system('git', 'fetch', @fetch_opts, 'origin',
                                 '+refs/heads/*:refs/heads/*') == 0
                 || exit_error "Error fetching git repository";
-        system('git', 'fetch', @fetch_submod, 'origin',
+        system('git', 'fetch', @fetch_opts, 'origin',
                                 '+refs/tags/*:refs/tags/*') == 0
                 || exit_error "Error fetching git repository";
         $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