Skip to content

Commit

Permalink
fix #6
Browse files Browse the repository at this point in the history
  • Loading branch information
sters committed Oct 26, 2021
1 parent cc9fb27 commit 6c47741
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions onstatic/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func RegisterHandler(s *http.ServeMux) {
"/unregister": http.HandlerFunc(handleUnregister),
"/": http.HandlerFunc(handleAll),
} {
path, handler := path, handler
handle := handler
if conf.Variables.AccessLog {
handle = func(rw http.ResponseWriter, r *http.Request) {
Expand Down
16 changes: 10 additions & 6 deletions onstatic/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package onstatic

import (
"crypto/sha1"
"errors"
"fmt"
"io/ioutil"
"os"
Expand Down Expand Up @@ -217,19 +218,22 @@ func doGitPull(repo *git.Repository, branchName string) error {
return failure.Wrap(err)
}

opt := &git.PullOptions{
err = repo.Fetch(&git.FetchOptions{
RemoteName: originName,
Auth: auth,
Force: true,
})
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
return failure.Wrap(err)
}

if branchName != "" {
opt.ReferenceName = plumbing.NewBranchReferenceName(branchName)
}

err = w.Pull(opt)
err = w.Checkout(&git.CheckoutOptions{
Branch: plumbing.NewRemoteReferenceName(originName, branchName),
Force: true,
})
if err != nil {
return failure.Wrap(err)
}

return nil
}

0 comments on commit 6c47741

Please sign in to comment.