Make actions in internal/repos unexported
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Elara 2022-11-30 21:47:07 -08:00
parent c0439a2b90
commit eaf49a4594
1 changed files with 18 additions and 18 deletions

View File

@ -132,15 +132,15 @@ func Pull(ctx context.Context, gdb *genji.DB, repos []types.Repo) error {
return nil return nil
} }
type ActionType uint8 type actionType uint8
const ( const (
ActionDelete ActionType = iota actionDelete actionType = iota
ActionUpdate actionUpdate
) )
type Action struct { type action struct {
Type ActionType Type actionType
File string File string
} }
@ -160,34 +160,34 @@ func processRepoChanges(ctx context.Context, repo types.Repo, r *git.Repository,
return err return err
} }
var actions []Action var actions []action
for _, fp := range patch.FilePatches() { for _, fp := range patch.FilePatches() {
from, to := fp.Files() from, to := fp.Files()
if to == nil { if to == nil {
actions = append(actions, Action{ actions = append(actions, action{
Type: ActionDelete, Type: actionDelete,
File: from.Path(), File: from.Path(),
}) })
} else if from == nil { } else if from == nil {
actions = append(actions, Action{ actions = append(actions, action{
Type: ActionUpdate, Type: actionUpdate,
File: to.Path(), File: to.Path(),
}) })
} else { } else {
if from.Path() != to.Path() { if from.Path() != to.Path() {
actions = append(actions, actions = append(actions,
Action{ action{
Type: ActionDelete, Type: actionDelete,
File: from.Path(), File: from.Path(),
}, },
Action{ action{
Type: ActionUpdate, Type: actionUpdate,
File: to.Path(), File: to.Path(),
}, },
) )
} else { } else {
actions = append(actions, Action{ actions = append(actions, action{
Type: ActionUpdate, Type: actionUpdate,
File: to.Path(), File: to.Path(),
}) })
} }
@ -208,7 +208,7 @@ func processRepoChanges(ctx context.Context, repo types.Repo, r *git.Repository,
for _, action := range actions { for _, action := range actions {
switch action.Type { switch action.Type {
case ActionDelete: case actionDelete:
scriptFl, err := oldCommit.File(action.File) scriptFl, err := oldCommit.File(action.File)
if err != nil { if err != nil {
return nil return nil
@ -229,7 +229,7 @@ func processRepoChanges(ctx context.Context, repo types.Repo, r *git.Repository,
if err != nil { if err != nil {
return err return err
} }
case ActionUpdate: case actionUpdate:
scriptFl, err := newCommit.File(action.File) scriptFl, err := newCommit.File(action.File)
if err != nil { if err != nil {
return nil return nil