Skip to content

Commit

Permalink
Don't keep repository & worktree open
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Aug 5, 2019
1 parent 550183b commit 50018c4
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,21 +125,23 @@ func main() {
}

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 {
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)
if err != nil {
fatal("cannot pull from repository: %s\n", err)
}

status, err := w.Status()
if err != nil {
fatal("cannot retrieve git status: %s\n", err)
Expand Down

0 comments on commit 50018c4

Please sign in to comment.