File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed
Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 66 "log"
77 "os"
88 "path/filepath"
9+ "time"
910)
1011
1112var configFilePath = flag .String ("config.file" , "git-backup.yml" , "The path to your config file." )
@@ -15,7 +16,14 @@ func main() {
1516 flag .Parse ()
1617
1718 config := loadConfig ()
18- for _ , source := range config .GetSources () {
19+ sources := config .GetSources ()
20+ if len (sources ) == 0 {
21+ log .Printf ("Found a config file at [%s] but detected no sources. Are you sure the file is properly formed?" , * configFilePath )
22+ os .Exit (111 )
23+ }
24+ repoCount := 0
25+ backupStart := time .Now ()
26+ for _ , source := range sources {
1927 sourceName := source .GetName ()
2028 log .Printf ("=== %s ===" , sourceName )
2129 if err := source .Test (); err != nil {
@@ -41,7 +49,9 @@ func main() {
4149 os .Exit (100 )
4250 }
4351 }
52+ repoCount ++
4453 }
54+ log .Printf ("Backed up %d repositories in %s" , repoCount , time .Now ().Sub (backupStart ))
4555}
4656
4757func loadConfig () gitbackup.Config {
Original file line number Diff line number Diff line change 11package git_backup
22
33import (
4- "gopkg.in/yaml.v2 "
4+ "gopkg.in/yaml.v3 "
55 "io"
66 "os"
77)
@@ -54,7 +54,7 @@ func LoadFile(path string) (out Config, err error) {
5454
5555func LoadReader (reader io.Reader ) (out Config , err error ) {
5656 dec := yaml .NewDecoder (reader )
57- dec .SetStrict (true )
57+ dec .KnownFields (true )
5858 err = dec .Decode (& out )
5959 out .setDefaults ()
6060 return
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ require (
77 github.com/google/go-github/v43 v43.0.0
88 github.com/xanzy/go-gitlab v0.60.0
99 golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c
10- gopkg.in/yaml.v2 v2.4.0
10+ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
1111)
1212
1313require (
@@ -34,4 +34,5 @@ require (
3434 google.golang.org/appengine v1.6.7 // indirect
3535 google.golang.org/protobuf v1.27.1 // indirect
3636 gopkg.in/warnings.v0 v0.1.2 // indirect
37+ gopkg.in/yaml.v2 v2.4.0 // indirect
3738)
You can’t perform that action at this time.
0 commit comments