@@ -6,20 +6,21 @@ import (
6
6
"time"
7
7
8
8
"github.com/aceberg/git-syr/internal/check"
9
+ "github.com/aceberg/git-syr/internal/models"
9
10
)
10
11
11
12
// Push - executes
12
13
// git add -A
13
14
// git commit -m `date`
14
15
// git push
15
16
// in repo
16
- func Push (path string ) {
17
+ func Push (repo models. Repo ) {
17
18
18
19
currentTime := time .Now ()
19
20
timeString := string (currentTime .Format ("2006-01-02 15:04:05" ))
20
21
21
- gitDir := "--git-dir=" + path + "/.git"
22
- gitTree := "--work-tree=" + path
22
+ gitDir := "--git-dir=" + repo . Path + "/.git"
23
+ gitTree := "--work-tree=" + repo . Path
23
24
24
25
cmd := exec .Command ("git" , gitDir , gitTree , "add" , "-A" )
25
26
out1 , err := cmd .CombinedOutput ()
@@ -29,9 +30,13 @@ func Push(path string) {
29
30
out2 , err := cmd .CombinedOutput ()
30
31
check .IfError (err )
31
32
32
- cmd = exec .Command ("git" , gitDir , gitTree , "push" )
33
+ if repo .AddPush != "" {
34
+ cmd = exec .Command ("git" , gitDir , gitTree , "push" , repo .AddPush )
35
+ } else {
36
+ cmd = exec .Command ("git" , gitDir , gitTree , "push" )
37
+ }
33
38
out3 , err := cmd .CombinedOutput ()
34
39
check .IfError (err )
35
40
36
- log .Println ("INFO: Push repo" , path , "\n " , string (out1 ), "\n " , string (out2 ), "\n " , string (out3 ))
41
+ log .Println ("INFO: Push repo" , repo . Path , "\n " , string (out1 ), "\n " , string (out2 ), "\n " , string (out3 ))
37
42
}
0 commit comments