mirror of
https://github.com/cooperspencer/gickup.git
synced 2025-05-11 17:55: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) {
|
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
|
var auth transport.AuthMethod
|
||||||
if repo.Token != "" {
|
if repo.Token != "" {
|
||||||
if repo.NoTokenUser {
|
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)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -602,7 +610,7 @@ func TempClone(repo types.Repo, tempdir string) (*git.Repository, error) {
|
||||||
|
|
||||||
return r, err
|
return r, err
|
||||||
} else {
|
} else {
|
||||||
r, err := git.PlainClone(tempdir, false, &git.CloneOptions{
|
r, err := git.PlainClone(tempdir, isBare, &git.CloneOptions{
|
||||||
URL: repo.URL,
|
URL: repo.URL,
|
||||||
Auth: auth,
|
Auth: auth,
|
||||||
SingleBranch: false,
|
SingleBranch: false,
|
||||||
|
|
2
main.go
2
main.go
|
@ -219,7 +219,7 @@ func backup(repos []types.Repo, conf *types.Conf) {
|
||||||
|
|
||||||
defer os.RemoveAll(tempdir)
|
defer os.RemoveAll(tempdir)
|
||||||
tempClonePath := path.Join(tempdir, r.Name)
|
tempClonePath := path.Join(tempdir, r.Name)
|
||||||
_, err = local.TempClone(r, tempClonePath)
|
_, err = local.TempCloneBare(r, tempClonePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == git.NoErrAlreadyUpToDate {
|
if err == git.NoErrAlreadyUpToDate {
|
||||||
log.Info().
|
log.Info().
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue