Fix
parent
82d9057b10
commit
f4bac41d11
|
@ -48,7 +48,7 @@ func (g Git) init() (r *git.Repository, w *git.Worktree, err error) {
|
|||
}
|
||||
if err != nil {
|
||||
// Delete old things
|
||||
_ = os.RemoveAll(g.filepath)
|
||||
g.destroyRepo()
|
||||
// Clone
|
||||
r, err = git.PlainClone(g.filepath, false, &git.CloneOptions{
|
||||
Auth: &gitHttp.BasicAuth{
|
||||
|
@ -72,6 +72,10 @@ func (g Git) init() (r *git.Repository, w *git.Worktree, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (g Git) destroyRepo() {
|
||||
_ = os.RemoveAll(g.filepath)
|
||||
}
|
||||
|
||||
func (g Git) push(repository *git.Repository) error {
|
||||
err := repository.Push(&git.PushOptions{
|
||||
Auth: &gitHttp.BasicAuth{
|
||||
|
@ -82,6 +86,8 @@ func (g Git) push(repository *git.Repository) error {
|
|||
if err == nil || err == git.NoErrAlreadyUpToDate {
|
||||
return nil
|
||||
} else {
|
||||
// Destroy repo to prevent errors when trying to create same post again
|
||||
g.destroyRepo()
|
||||
return errors.New("failed to push to remote")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue