oioss
1package utils2
3import (4"log"5
6"github.com/go-git/go-git/v5"7)
8
9func UpdateGitRepo(path string) error {10log.Println("git init local update repo: ", path)11r, err := git.PlainOpen(path)12if err != nil {13return err14}15
16w, err := r.Worktree()17if err != nil {18return err19}20
21log.Println("git local pull origin")22err = w.Pull(&git.PullOptions{RemoteName: "origin"})23if err != nil {24return err25}26
27ref, err := r.Head()28if err != nil {29return err30}31
32commit, err := r.CommitObject(ref.Hash())33if err != nil {34return err35}36
37commit = commit38// log.Println(commit) //debug39log.Println("git pull: done")40return nil41}
42