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 error and
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 ebfa51a commit f51bdb9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion 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 @@ -313,9 +314,21 @@ func (l *Client) Commit(info git.Commit, commitOpts ...repository.CommitOption)
}
defer index.Free()

if err = util.Walk(l.repoFS, "",
walkPath := ""
// Workaround bug in MacOS.
if runtime.GOOS == "darwin" {
walkPath = l.path
}

if err = util.Walk(l.repoFS, walkPath,
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 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 f51bdb9

Please sign in to comment.