]> source.dussan.org Git - gitea.git/commit
Don't remove all mirror repository's releases when mirroring (#28817)
authorLunny Xiao <xiaolunwen@gmail.com>
Fri, 26 Jan 2024 06:18:19 +0000 (14:18 +0800)
committerGitHub <noreply@github.com>
Fri, 26 Jan 2024 06:18:19 +0000 (06:18 +0000)
commit534917d57670d82703567131e2b33fd945e6f8cb
treefea6941d86621754368e1c1f19b0e5b89a48338a
parentba24e0ba61b1b66f58c8448f27272d1d6d14f60c
Don't remove all mirror repository's releases when mirroring (#28817)

Fix #22066

# Purpose

This PR fix the releases will be deleted when mirror repository sync the
tags.

# The problem

In the previous implementation of #19125. All releases record in
databases of one mirror repository will be deleted before sync.
Ref:
https://github.com/go-gitea/gitea/pull/19125/files#diff-2aa04998a791c30e5a02b49a97c07fcd93d50e8b31640ce2ddb1afeebf605d02R481

# The Pros

This PR introduced a new method which will load all releases from
databases and all tags on git data into memory. And detect which tags
needs to be inserted, which tags need to be updated or deleted. Only
tags releases(IsTag=true) which are not included in git data will be
deleted, only tags which sha1 changed will be updated. So it will not
delete any real releases include drafts.

# The Cons

The drawback is the memory usage will be higher than before if there are
many tags on this repository. This PR defined a special release struct
to reduce columns loaded from database to memory.
modules/repository/repo.go
modules/repository/repo_test.go [new file with mode: 0644]