diff options
author | Christopher Baines <mail@cbaines.net> | 2022-11-07 20:01:44 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2022-11-07 20:01:44 +0100 |
commit | 0072112a6a9be1f435c4333c807d247c6b9d090d (patch) | |
tree | af82edf821495001ed481cfb0610ac508c270092 | |
parent | 5a7a9fc2fbb59b1516c736c8efc7417314c357be (diff) | |
download | qa-frontpage-0072112a6a9be1f435c4333c807d247c6b9d090d.tar qa-frontpage-0072112a6a9be1f435c4333c807d247c6b9d090d.tar.gz |
Handle re-creating branches when new Patchwork series are present
By checking when the HEAD commit on the branch was committed.
-rw-r--r-- | guix-qa-frontpage/manage-patch-branches.scm | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/guix-qa-frontpage/manage-patch-branches.scm b/guix-qa-frontpage/manage-patch-branches.scm index 78854b9..0d43fa2 100644 --- a/guix-qa-frontpage/manage-patch-branches.scm +++ b/guix-qa-frontpage/manage-patch-branches.scm @@ -1,5 +1,6 @@ (define-module (guix-qa-frontpage manage-patch-branches) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-19) #:use-module (srfi srfi-71) #:use-module (ice-9 match) #:use-module (ice-9 popen) @@ -83,6 +84,22 @@ (cons (match:substring issue-number-match 1) branches)))))))))) +(define (get-git-branch-head-committer-date branch) + (with-bare-git-repository + (lambda () + (let ((pipe (open-pipe* OPEN_READ + "git" "show" "-s" "--format=%ci" branch "--"))) + (let loop ((line (read-line pipe)) + (lines '())) + (if (eof-object? line) + (begin + (close-pipe pipe) + + (string->date (first lines) + "~Y-~m-~d ~H:~M:~S ~z")) + (loop (read-line pipe) + (cons line lines)))))))) + (define* (pwclient-check-create patch-id #:key @@ -274,9 +291,20 @@ (for-each (match-lambda ((issue-number . patchwork-series) - (unless (member (number->string issue-number) - issue-numbers - string=?) + (when (or (not + (member (number->string issue-number) + issue-numbers + string=?)) + + ;; Does the branch need re-creating with a new series? + (time<? + (date->time-utc + (get-git-branch-head-committer-date + (simple-format #f "patches/issue-~A" issue-number))) + (date->time-utc + (string->date + (assoc-ref patchwork-series "date") + "~Y-~m-~dT~H:~M:~S")))) (create-branch-for-issue issue-number (number->string (assoc-ref patchwork-series |