Skip to content

Commit

Permalink
libgit2: Adhoc fix for darwin
Browse files Browse the repository at this point in the history
When running in MacOS, the util.Walk func may incorrectly
say that the current dir is not inside the workdir set in
the fs. To workaround the issue we check for the OS and
error, and finally ensure that the path is the same as the
workdir set.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
  • Loading branch information
Paulo Gomes committed Dec 7, 2022
1 parent f7a2814 commit a062e1e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions git/libgit2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"io"
"net/url"
"os"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -316,6 +317,12 @@ func (l *Client) Commit(info git.Commit, commitOpts ...repository.CommitOption)
if err = util.Walk(l.repoFS, "",
func(path string, info os.FileInfo, err error) error {
if err != nil {
// Workaround bug in MacOS. This code is being sunsetting
// soon as part of libgit2 decommissioning, therefore no
// need for a more robust fix.
if runtime.GOOS == "darwin" && strings.Contains(err.Error(), "path outside working dir") && path == l.path {
return nil
}
return err
}
// skip symlinks and any files that are within ".git/"
Expand Down

0 comments on commit a062e1e

Please sign in to comment.