Skip to content

Commit 4c0290c

Browse files
committed
Additional push command
1 parent 68b12a2 commit 4c0290c

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

internal/git/push.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@ import (
66
"time"
77

88
"github.com/aceberg/git-syr/internal/check"
9+
"github.com/aceberg/git-syr/internal/models"
910
)
1011

1112
// Push - executes
1213
// git add -A
1314
// git commit -m `date`
1415
// git push
1516
// in repo
16-
func Push(path string) {
17+
func Push(repo models.Repo) {
1718

1819
currentTime := time.Now()
1920
timeString := string(currentTime.Format("2006-01-02 15:04:05"))
2021

21-
gitDir := "--git-dir=" + path + "/.git"
22-
gitTree := "--work-tree=" + path
22+
gitDir := "--git-dir=" + repo.Path + "/.git"
23+
gitTree := "--work-tree=" + repo.Path
2324

2425
cmd := exec.Command("git", gitDir, gitTree, "add", "-A")
2526
out1, err := cmd.CombinedOutput()
@@ -29,9 +30,13 @@ func Push(path string) {
2930
out2, err := cmd.CombinedOutput()
3031
check.IfError(err)
3132

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+
}
3338
out3, err := cmd.CombinedOutput()
3439
check.IfError(err)
3540

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))
3742
}

internal/sync/sync-repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func syncRepo(repo models.Repo, quit chan bool) {
2727
git.Pull(repo.Path)
2828
}
2929
if repo.Push == "yes" && git.CheckIfPush(repo.Path) {
30-
git.Push(repo.Path)
30+
git.Push(repo)
3131
}
3232
lastDate = time.Now()
3333
}

0 commit comments

Comments
 (0)