File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -9,5 +9,6 @@ func all() []Subcommand {
9
9
return []Subcommand {
10
10
Init {},
11
11
Update {},
12
+ UpdateAll {},
12
13
}
13
14
}
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+ "git-bundle-server/internal/core"
6
+ "os"
7
+ "os/exec"
8
+ )
9
+
10
+ type UpdateAll struct {}
11
+
12
+ func (UpdateAll ) subcommand () string {
13
+ return "update-all"
14
+ }
15
+
16
+ func (UpdateAll ) run (args []string ) error {
17
+ exe , err := os .Executable ()
18
+ if err != nil {
19
+ return fmt .Errorf ("failed to get path to execuable: %w" , err )
20
+ }
21
+
22
+ repos , err := core .GetRepositories ()
23
+ if err != nil {
24
+ return err
25
+ }
26
+
27
+ for route := range repos {
28
+ cmd := exec .Command (exe , "update" , route )
29
+ cmd .Stderr = os .Stderr
30
+ cmd .Stdout = os .Stdout
31
+
32
+ err := cmd .Start ()
33
+ if err != nil {
34
+ return fmt .Errorf ("git command failed to start: %w" , err )
35
+ }
36
+
37
+ err = cmd .Wait ()
38
+ if err != nil {
39
+ return fmt .Errorf ("git command returned a failure: %w" , err )
40
+ }
41
+ }
42
+
43
+ return nil
44
+ }
You can’t perform that action at this time.
0 commit comments