Skip to content

Commit d8c1598

Browse files
authored
Fix private repo cloning (#76)
* Always use token for cloning via HTTPS On GitLab for some reason the `repo.Private` always returns false even if the repo is actually private, which means this code is never executed and the `git` client asks for a username and password to clone. It would make sense to use the token for cloning any type of repo, as it would prevent the need for asking these details. Tested on my local build with gitlab.com and it works as expected. * separate private repo check
1 parent b4a3713 commit d8c1598

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

backup.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ func backUp(backupDir string, repo *Repository, bare bool, wg *sync.WaitGroup) (
4545
log.Printf("Cloning %s\n", repo.Name)
4646
log.Printf("%#v\n", repo)
4747

48-
if repo.Private && useHTTPSClone != nil && *useHTTPSClone && ignorePrivate != nil && !*ignorePrivate {
48+
if repo.Private && ignorePrivate != nil && !*ignorePrivate {
49+
log.Printf("Skipping %s as it is a private repo.\n", repo.Name)
50+
return stdoutStderr, nil
51+
}
52+
53+
if useHTTPSClone != nil && *useHTTPSClone {
4954
// Add username and token to the clone URL
5055
// https://gitlab.com/amitsaha/testproject1 => https://amitsaha:[email protected]/amitsaha/testproject1
5156
u, err := url.Parse(repo.CloneURL)

0 commit comments

Comments
 (0)