forked from amitsaha/gitbackup
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
54 lines (46 loc) · 1.18 KB
/
Copy pathmain.go
File metadata and controls
54 lines (46 loc) · 1.18 KB
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
46
47
48
49
50
51
52
53
54
package main
import (
"fmt"
"log"
"os"
)
// MaxConcurrentClones is the upper limit of the maximum number of
// concurrent git clones
//const MaxConcurrentClones = 20
const defaultMaxUserMigrationRetry = 5
var gitHostToken string
var useHTTPSClone *bool
var ignorePrivate *bool
var gitHostUsername string
// The services we know of and their default public host names
var knownServices = map[string]string{
"github": "github.com",
"gitlab": "gitlab.com",
"bitbucket": "bitbucket.org",
}
func main() {
c, err := initConfig(os.Args[1:])
if err != nil {
log.Fatal(err)
}
err = validateConfig(c)
if err != nil {
log.Fatal(err)
}
client := newClient(c.service, c.gitHostURL)
var executionErr error
// TODO implement validation of options so that we don't
// allow multiple operations at one go
if c.githubListUserMigrations {
handleGithubListUserMigrations(client, c)
} else if c.githubCreateUserMigration {
handleGithubCreateUserMigration(client, c)
} else {
executionErr = handleGitRepositoryClone(client, c)
}
if executionErr != nil {
log.Fatalln(fmt.Sprintf("execution error -> %v", executionErr.Error()))
} else {
log.Println("backup finished successfully")
}
}