Make S3 backups bare (#316)

This commit is contained in:
Sjors Holtrop 2025-04-28 11:58:00 +02:00 committed by GitHub
parent 4688acb8cd
commit 533b98ba0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View file

@ -521,6 +521,14 @@ func VerifyHost(host string, remote net.Addr, key gossh.PublicKey) error {
}
func TempClone(repo types.Repo, tempdir string) (*git.Repository, error) {
return tempCloneBase(repo, tempdir, false)
}
func TempCloneBare(repo types.Repo, tempdir string) (*git.Repository, error) {
return tempCloneBase(repo, tempdir, true)
}
func tempCloneBase(repo types.Repo, tempdir string, isBare bool) (*git.Repository, error) {
var auth transport.AuthMethod
if repo.Token != "" {
if repo.NoTokenUser {
@ -549,7 +557,7 @@ func TempClone(repo types.Repo, tempdir string) (*git.Repository, error) {
repo.URL = strings.Replace(repo.URL, "https://", fmt.Sprintf("https://xyz:%s@", repo.Token), -1)
}
err = gitc.Clone(repo.URL, tempdir, false, false)
err = gitc.Clone(repo.URL, tempdir, isBare, false)
if err != nil {
return nil, err
}
@ -602,7 +610,7 @@ func TempClone(repo types.Repo, tempdir string) (*git.Repository, error) {
return r, err
} else {
r, err := git.PlainClone(tempdir, false, &git.CloneOptions{
r, err := git.PlainClone(tempdir, isBare, &git.CloneOptions{
URL: repo.URL,
Auth: auth,
SingleBranch: false,

View file

@ -219,7 +219,7 @@ func backup(repos []types.Repo, conf *types.Conf) {
defer os.RemoveAll(tempdir)
tempClonePath := path.Join(tempdir, r.Name)
_, err = local.TempClone(r, tempClonePath)
_, err = local.TempCloneBare(r, tempClonePath)
if err != nil {
if err == git.NoErrAlreadyUpToDate {
log.Info().