Properly handle deleting commits that occur on multiple branches
This commit is contained in:
parent
b5fbde5ac8
commit
335715bc72
1 changed files with 20 additions and 4 deletions
|
|
@ -146,7 +146,7 @@ AND id NOT IN (
|
|||
(delete-unreferenced-lint-checkers))))
|
||||
|
||||
(define (delete-revisions-from-branch conn git-repository-id branch-name commits)
|
||||
(define (delete-jobs conn)
|
||||
(define (delete-jobs conn commits)
|
||||
(for-each
|
||||
(lambda (table)
|
||||
(exec-query
|
||||
|
|
@ -217,9 +217,7 @@ WHERE id IN (
|
|||
'delete-revisions-from-branch)
|
||||
|
||||
(exec-query conn "SET LOCAL lock_timeout = '5s';")
|
||||
|
||||
(delete-from-git-commits conn)
|
||||
(delete-jobs conn)
|
||||
|
||||
(let ((git-branch-id
|
||||
(git-branch-for-repository-and-name conn
|
||||
|
|
@ -232,7 +230,25 @@ WHERE id IN (
|
|||
DROP TABLE IF EXISTS package_derivations_by_guix_revision_range_git_branch_"
|
||||
(number->string git-branch-id) ";")))
|
||||
|
||||
(delete-guix-revisions conn git-repository-id commits))))
|
||||
(let ((now-unreferenced-commits
|
||||
(filter
|
||||
(lambda (commit)
|
||||
(let ((result
|
||||
(null?
|
||||
(exec-query
|
||||
conn
|
||||
"SELECT 1 FROM git_commits WHERE commit = $1"
|
||||
commit))))
|
||||
(unless result
|
||||
(simple-format (current-error-port)
|
||||
"skipping ~A because it's still referenced\n"
|
||||
commit))
|
||||
result))
|
||||
commits)))
|
||||
(delete-jobs conn now-unreferenced-commits)
|
||||
(delete-guix-revisions conn
|
||||
git-repository-id
|
||||
now-unreferenced-commits)))))
|
||||
(lambda (key . args)
|
||||
(simple-format
|
||||
(current-error-port)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue