Skip to content

Commit

Permalink
Merge pull request #39 from NYULibraries/dlfa-222_go-ead-indexer-pack…
Browse files Browse the repository at this point in the history
…age-git

update ListEADFilesForCommit() to use errors.Join
  • Loading branch information
jgpawletko authored Jan 24, 2025
2 parents 488fcce + 3c53520 commit 78e7bcd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/git/git.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package git

import (
"errors"
"fmt"
"strings"

gogit "github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
Expand Down Expand Up @@ -66,20 +66,20 @@ func ListEADFilesForCommit(repoPath string, thisCommitHashString string) (map[st
return nil, err
}

var estr []string
var errs []error
for _, fileChange := range patch.FilePatches() {
from, to := fileChange.Files()
k, v := classifyFileChange(from, to)
if v == Unknown {
// unable to determine the type of change
estr = append(estr, fmt.Sprintf("unable to determine file transition: commit %s, parent commit: %s; File: from '%s', to '%s'", thisCommitHashString, parentHash.String(), getPath(from), getPath(to)))
errs = append(errs, fmt.Errorf("unable to determine file transition: Commits: commit '%s', parent: '%s', Files: from '%s', to '%s'", thisCommitHashString, parentHash.String(), getPath(from), getPath(to)))
continue
}

operations[k] = v
}
if len(estr) != 0 {
return nil, fmt.Errorf("%s", strings.Join(estr, "\n"))
if len(errs) != 0 {
return nil, errors.Join(errs...)
}

return operations, nil
Expand Down

0 comments on commit 78e7bcd

Please sign in to comment.