Staging changes
Some checks reported errors
continuous-integration/drone/push Build was killed
continuous-integration/drone/pr Build was killed

This commit is contained in:
Jacob Hrbek 2022-09-22 20:23:42 +02:00
parent e5365cb96d
commit a2d8eaad30
Signed by: kreyren
GPG Key ID: 667F0DAFAF09BA2B
2 changed files with 49 additions and 11 deletions

@ -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

@ -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 <http://www.gnu.org/licenses>
#;(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