-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
45 lines (37 loc) 路 998 Bytes
/
Copy pathmain.go
File metadata and controls
45 lines (37 loc) 路 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"github.com/Snider/Borg/pkg/github"
"github.com/Snider/Borg/pkg/vcs"
)
func main() {
log.Println("Collecting all repositories for a user...")
repos, err := github.NewGithubClient(http.DefaultClient).GetPublicRepos(context.Background(), "Snider")
if err != nil {
log.Fatalf("Failed to get public repos: %v", err)
}
cloner := vcs.NewGitCloner()
for _, repo := range repos {
log.Printf("Cloning %s...", repo)
dn, err := cloner.CloneGitRepository(fmt.Sprintf("https://github.com/%s", repo), nil)
if err != nil {
log.Printf("Failed to clone %s: %v", repo, err)
continue
}
tarball, err := dn.ToTar()
if err != nil {
log.Printf("Failed to serialize %s to tar: %v", repo, err)
continue
}
err = os.WriteFile(fmt.Sprintf("%s.dat", repo), tarball, 0644)
if err != nil {
log.Printf("Failed to write %s.dat: %v", repo, err)
continue
}
log.Printf("Successfully created %s.dat", repo)
}
}