MCPcopy Create free account
hub / github.com/amitsaha/gitbackup / backUp

Function backUp

backup.go:33–47  ·  view source on GitHub ↗

Check if we have a copy of the repo already, if we do, we update the repo, else we do a fresh clone

(backupDir string, repo *Repository, bare bool, wg *sync.WaitGroup)

Source from the content-addressed store, hash-verified

31// Check if we have a copy of the repo already, if
32// we do, we update the repo, else we do a fresh clone
33func backUp(backupDir string, repo *Repository, bare bool, wg *sync.WaitGroup) ([]byte, error) {
34 defer wg.Done()
35
36 repoDir := getRepoDir(backupDir, repo, bare)
37
38 _, err := appFS.Stat(repoDir)
39
40 var stdoutStderr []byte
41 if err == nil {
42 stdoutStderr, err = updateExistingRepo(repoDir, repo.Name, bare)
43 } else {
44 stdoutStderr, err = cloneNewRepo(repoDir, repo, bare)
45 }
46 return stdoutStderr, err
47}
48
49// getRepoDir returns the directory path for a repository
50func getRepoDir(backupDir string, repo *Repository, bare bool) string {

Callers 3

handleGitRepositoryCloneFunction · 0.85
TestBackupFunction · 0.85
TestBareBackupFunction · 0.85

Calls 3

getRepoDirFunction · 0.85
updateExistingRepoFunction · 0.85
cloneNewRepoFunction · 0.85

Tested by 2

TestBackupFunction · 0.68
TestBareBackupFunction · 0.68