refactor(git): move commit exists function to project
This commit is contained in:
parent
d46a9f0883
commit
1d949f1fb8
2 changed files with 19 additions and 18 deletions
|
@ -1,10 +1,8 @@
|
|||
package git
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ProtonMail/go-crypto/openpgp"
|
||||
|
@ -95,22 +93,6 @@ func (c *Commit) Create(msg string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *Commit) Exists(uid string, id uint) bool {
|
||||
commitIter, err := c.project.repository.Log(&git.LogOptions{})
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
err = commitIter.ForEach(func(commit *object.Commit) error {
|
||||
if strings.Contains(commit.Message, fmt.Sprintf("Update %s", uid)) &&
|
||||
strings.Contains(commit.Message, fmt.Sprintf("version %d", id)) {
|
||||
return errors.New("version already committed")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return err != nil
|
||||
}
|
||||
|
||||
func (c *Commit) addContent() error {
|
||||
file, err := c.project.worktree.Filesystem.Create(c.Filename)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue