forgejo: Support deletion of branches when a pull request is closed.
This commit is contained in:
parent
8e7da32f55
commit
254998a561
3 changed files with 29 additions and 3 deletions
|
|
@ -43,7 +43,8 @@
|
|||
forgejo-pull-request-draft?
|
||||
forgejo-pull-request-body
|
||||
|
||||
enqueue-job-for-pull-request))
|
||||
enqueue-job-for-pull-request
|
||||
mark-pull-request-branch-for-deletion))
|
||||
|
||||
;; The JSON data structures below were copied from Cuirass.
|
||||
|
||||
|
|
@ -125,3 +126,22 @@
|
|||
|
||||
(enqueue-load-new-guix-revision-job conn repository-id
|
||||
commit label))))
|
||||
|
||||
(define (mark-pull-request-branch-for-deletion conn pull-request)
|
||||
"Mark the branch associated with @var{pull-request}, a pull request being
|
||||
closed, for deletion."
|
||||
(let* ((url (forgejo-pull-request-url pull-request))
|
||||
(repository-id (git-repository-url->git-repository-id
|
||||
conn url #:create-if-missing? #f)))
|
||||
(when repository-id
|
||||
(let* ((date (time-utc->date (current-time time-utc)))
|
||||
(reference (forgejo-pull-request-head pull-request))
|
||||
(branch (forgejo-repository-reference-ref reference))
|
||||
(branch-id (git-branch-for-repository-and-name
|
||||
conn repository-id branch)))
|
||||
(when branch-id
|
||||
;; Insert a commit entry with the empty string: this is interpreted
|
||||
;; as BRANCH-ID being a candidate for deletion.
|
||||
(format #t "marking pull request branch ~s of ~s for deletion~%"
|
||||
branch url)
|
||||
(insert-git-commit-entry conn branch-id "" date))))))
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@
|
|||
('synchronized ;pull request is updated
|
||||
(enqueue-job-for-pull-request conn pull-request))
|
||||
('closed ;closed or merged
|
||||
#f)
|
||||
(mark-pull-request-branch-for-deletion conn pull-request))
|
||||
(_ ;other action
|
||||
(render-json '((error . "unknown action"))
|
||||
#:code 404)))))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue