Check worktree clean when pulling
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
8236bb37f0
commit
e409bbb342
20
repo/repo.go
20
repo/repo.go
|
@ -9,6 +9,8 @@ import (
|
|||
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||
)
|
||||
|
||||
var ErrWorktreeNotClean = errors.New("worktree is not clean")
|
||||
|
||||
const Path = "./beancount"
|
||||
|
||||
var repo *git.Repository
|
||||
|
@ -46,10 +48,20 @@ func pull() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = w.Pull(&git.PullOptions{Auth: &http.BasicAuth{
|
||||
Username: config.Cfg.Username,
|
||||
Password: config.Cfg.Password,
|
||||
}})
|
||||
err = w.Pull(&git.PullOptions{
|
||||
Force: true,
|
||||
Auth: &http.BasicAuth{
|
||||
Username: config.Cfg.Username,
|
||||
Password: config.Cfg.Password,
|
||||
},
|
||||
})
|
||||
status, err := w.Status()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !status.IsClean() {
|
||||
return ErrWorktreeNotClean
|
||||
}
|
||||
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue