Added -pull and -push flags

This commit is contained in:
Christian Muehlhaeuser
2019-08-05 22:26:44 +02:00
parent 50018c4bdf
commit 1ea5b7cd31
2 changed files with 73 additions and 57 deletions

View File

@@ -50,10 +50,20 @@ gitomatic -privkey ~/.ssh/id_rsa <path>
gitomatic -username "someone" -password "mypass" <path>
```
Other parameters:
If you want to pull new changes but don't create commits (or vice versa):
```
gitomatic -pull=true -push=false <path>
```
You can control how often gitomatic checks for changes:
```
gitomatic -interval 30m <path>
gitomatic -author "John Doe" <path>
gitomatic -email "some@mail.tld" <path>
```
Change the commit author's name and email:
```
gitomatic -author "John Doe" -email "some@mail.tld" <path>
```

View File

@@ -16,6 +16,8 @@ import (
)
var (
pull = flag.Bool("pull", true, "automatically pull changes")
push = flag.Bool("push", true, "automatically push changes")
author = flag.String("author", "gitomatic", "author name for git commits")
email = flag.String("email", "gitomatic@fribbledom.com", "email address for git commits")
interval = flag.String("interval", "1m", "how often to check for changes")
@@ -137,11 +139,14 @@ func main() {
fatal("cannot access repository: %s\n", err)
}
if *pull {
err = gitPull(r, w, auth)
if err != nil {
fatal("cannot pull from repository: %s\n", err)
}
}
if *push {
status, err := w.Status()
if err != nil {
fatal("cannot retrieve git status: %s\n", err)
@@ -198,6 +203,7 @@ func main() {
fatal("cannot push: %s\n", err)
}
}
}
log.Printf("Sleeping until next check in %s...\n", timeout)
time.Sleep(timeout)