mirror of
https://github.com/taigrr/gitomatic.git
synced 2026-04-02 03:09:10 -07:00
Don't keep repository & worktree open
This commit is contained in:
18
main.go
18
main.go
@@ -125,21 +125,23 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
path := flag.Args()[0]
|
path := flag.Args()[0]
|
||||||
r, err := git.PlainOpen(path)
|
|
||||||
if err != nil {
|
|
||||||
fatal("cannot open repository: %s\n", err)
|
|
||||||
}
|
|
||||||
w, err := r.Worktree()
|
|
||||||
if err != nil {
|
|
||||||
fatal("cannot access repository: %s\n", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
log.Println("Checking repository:", path)
|
log.Println("Checking repository:", path)
|
||||||
|
r, err := git.PlainOpen(path)
|
||||||
|
if err != nil {
|
||||||
|
fatal("cannot open repository: %s\n", err)
|
||||||
|
}
|
||||||
|
w, err := r.Worktree()
|
||||||
|
if err != nil {
|
||||||
|
fatal("cannot access repository: %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user