From a2d8eaad301b92dc671b800a6f893b1944df301c Mon Sep 17 00:00:00 2001 From: Jacob Hrbek Date: Thu, 22 Sep 2022 20:23:42 +0200 Subject: [PATCH] Staging changes --- automation/common.scm | 7 ++++- automation/pull-upstream.scm | 53 +++++++++++++++++++++++++++++------- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/automation/common.scm b/automation/common.scm index 2be4aed5df..fea08d415f 100755 --- a/automation/common.scm +++ b/automation/common.scm @@ -14,6 +14,11 @@ exec guile -s "$0" "$@" ;;; GNU Guile script library for definitions used for automation ;;; String containing the full path to the project's repository -(define %repodir (string-append (dirname (current-filename)) "/..")) +(define %repo-dir (string-append (dirname (current-filename)) "/..")) + +(define (get-variable name) + "Ensure that the environment variable NAME exists" + (or (getenv name) + (error (format #f "Environment variable not set: ~a" name)))) ;;; common.scm ends here diff --git a/automation/pull-upstream.scm b/automation/pull-upstream.scm index aec0c5a4f6..95250578e8 100755 --- a/automation/pull-upstream.scm +++ b/automation/pull-upstream.scm @@ -9,19 +9,52 @@ exec guile -s "$0" "$@" ;;;C ;;;C You should have received a copy of the GNU General Public license along with this project. If not, see -#;(use-modules - (git) - (git checkout)) +(define-module (devops-tools sync-git-repo) + #:use-module (ice-9 optargs) + ;#:use-module (git) + ;#:use-module ((git checkout) #:prefix git:) + #:use-module (devops-tools hotfixes) + #:use-module (devops-tools utils) + #:export (sync-git-repo)) -;;; GNU Guile script to keep the 'upstream' branch up to date with upstream repository +;;; Commentary: +;;; +;;; FIXME-DOCS +;;; +;;; Code: -(load (string-append (dirname (current-filename)) "/common.scm")) -(load (string-append (dirname (current-filename)) "/hotfixes.scm")) +(define* (sync-git-repo #:key + (source-repo (error "Key not provided: source-repo")) + (source-branch (error "Key not provided: source-branch")) + (target-repo (error "Key not provided: target-repo")) + (target-branch (error "Key not provided: target-branch")) + (push? #f) + (username (unless (false? push) (error "Key not provided: username"))) + (token (unless (false? push) (error "Key not provided: token"))) + (forge (unless (false? push) (error "Key not provided: forge")))) -(git:checkout-index %repodir "upstream") + "Sync SOURCE git repository with SOURCE-BRANCH to *local* TARGET repository's TARGET-BRANCH including pushing changes to optional FORGE, requires USERNAME and TOKEN to push changes. -(git:pull %repodir) +This procedure is designed to manage pull-based mirroring" -(git:push %repodir "upstream") + ;; FIXME(Krey): Sanity for inputs -;;;X pull-upstream.scm ends here + (git:checkout-index target-repo target-branch) + (git:pull target-repo) + + ;; FIXME(Krey): Regex forge + + (unless (string-null? push?) (git:push target-repo + (append-string "https://" username ":" token "@" forge "/" repo-owner "/" repo-name ".git") + target-branch))) + +(sync-git-repository #:source-repo "https://git.savannah.gnu.org/git/guix.git" + #:source-branch "master" + #:target-repo (append-string (dirname (current-filename)) "/..") + #:target-branch "upstream" + #:push? #t + #:username (get-variable "USERNAME") + #:token (get-variable "TOKEN") + #:forge "https://git.dotya.ml/kreyren/guix-kreyren.git") + +;;; sync-git-repo.scm ends here