Subject: [bug#74552] [PATCH 2/3] Abstract git fetch invocations into fetch-remote! function

From: Noé Lopez <[email-masked]>
Date: Wed, 27 Nov 2024 00:01:14 +0100

From: Noé Lopez <[email-masked]>

---
 guix-qa-frontpage/git-repository.scm        | 12 +++++++++---
 guix-qa-frontpage/manage-patch-branches.scm |  6 +++---
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/guix-qa-frontpage/git-repository.scm b/guix-qa-frontpage/git-repository.scm
index 2140c1e..0d31fe6 100644
--- a/guix-qa-frontpage/git-repository.scm
+++ b/guix-qa-frontpage/git-repository.scm
@@ -16,6 +16,7 @@
   #:export (%git-repository-location
 
             ensure-repository-exists!
+	    fetch-remote!
             update-repository!
             with-bare-git-repository
             with-git-worktree
@@ -55,13 +56,18 @@
           (invoke "git" "config" "user.name" "Guix Patches Tester")
           (invoke "git" "config" "user.email" "")))))))
 
+(define* (fetch-remote! remote #:rest additional-args)
+  (let ((args `("git" "fetch" "--prune"
+		,@additional-args ,remote)))
+    (apply invoke args)))
+
 (define (update-repository!)
   (with-bare-git-repository
    (lambda ()
      (invoke "git" "prune")
-     (invoke "git" "fetch" "--prune" "origin")
-     (invoke "git" "fetch" "--prune" "patches")
-     (invoke "git" "fetch" "--force" "--tags" "patches"))))
+     (fetch-remote! "origin")
+     (fetch-remote! "patches")
+     (fetch-remote! "patches" "--force" "--tags"))))
 
 (define (with-bare-git-repository thunk)
   (ensure-repository-exists!)
diff --git a/guix-qa-frontpage/manage-patch-branches.scm b/guix-qa-frontpage/manage-patch-branches.scm
index fc389e1..b725113 100644
--- a/guix-qa-frontpage/manage-patch-branches.scm
+++ b/guix-qa-frontpage/manage-patch-branches.scm
@@ -64,7 +64,7 @@
 
   (with-bare-git-repository
    (lambda ()
-     (run "git" "fetch" "--prune" "patches")
+     (fetch-remote! "origin")
 
      (let ((pipe (open-pipe* OPEN_READ
                              "git" "ls-remote" "--heads" "patches")))
@@ -142,7 +142,7 @@
           latest-processed-master-revision
           (with-bare-git-repository
            (lambda ()
-             (invoke "git" "fetch" "--prune" "origin")
+             (fetch-remote! "origin")
              (invoke-read-line "git" "show-ref" "--hash"
                                (string-append "origin/" branch)))))))
 
@@ -262,7 +262,7 @@
       (begin
         (with-bare-git-repository
          (lambda ()
-           (invoke "git" "fetch" "--prune" "origin")
+	   (fetch-remote! "origin")
            (system* "git" "worktree" "remove" "--force"
                     (simple-format #f "../issue-~A" issue-number))
            (system* "git" "branch" "-D"
-- 
2.46.0