mirror of
https://github.com/cooperspencer/gickup.git
synced 2025-05-10 17:25:34 +02:00
Make S3 backups bare (#316)
This commit is contained in:
parent
4688acb8cd
commit
533b98ba0c
2 changed files with 11 additions and 3 deletions
|
@ -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,
|
||||
|
|
2
main.go
2
main.go
|
@ -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().
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue