mirror of
https://github.com/taigrr/gitomatic.git
synced 2026-04-02 03:09:10 -07:00
Added -pull and -push flags
This commit is contained in:
16
README.md
16
README.md
@@ -50,10 +50,20 @@ gitomatic -privkey ~/.ssh/id_rsa <path>
|
|||||||
gitomatic -username "someone" -password "mypass" <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 -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>
|
||||||
```
|
```
|
||||||
|
|||||||
6
main.go
6
main.go
@@ -16,6 +16,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
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")
|
author = flag.String("author", "gitomatic", "author name for git commits")
|
||||||
email = flag.String("email", "gitomatic@fribbledom.com", "email address 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")
|
interval = flag.String("interval", "1m", "how often to check for changes")
|
||||||
@@ -137,11 +139,14 @@ func main() {
|
|||||||
fatal("cannot access repository: %s\n", err)
|
fatal("cannot access repository: %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *pull {
|
||||||
err = gitPull(r, w, auth)
|
err = gitPull(r, w, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal("cannot pull from repository: %s\n", err)
|
fatal("cannot pull from repository: %s\n", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if *push {
|
||||||
status, err := w.Status()
|
status, err := w.Status()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal("cannot retrieve git status: %s\n", err)
|
fatal("cannot retrieve git status: %s\n", err)
|
||||||
@@ -198,6 +203,7 @@ func main() {
|
|||||||
fatal("cannot push: %s\n", err)
|
fatal("cannot push: %s\n", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("Sleeping until next check in %s...\n", timeout)
|
log.Printf("Sleeping until next check in %s...\n", timeout)
|
||||||
time.Sleep(timeout)
|
time.Sleep(timeout)
|
||||||
|
|||||||
Reference in New Issue
Block a user