-
Notifications
You must be signed in to change notification settings - Fork 503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: lookup the right git binary on WSL #1477
Conversation
Signed-off-by: CrazyMax <[email protected]>
build/git.go
Outdated
@@ -50,30 +51,45 @@ func getGitAttributes(ctx context.Context, contextPath string, dockerfilePath st | |||
|
|||
gitc, err := gitutil.New(gitutil.WithContext(ctx), gitutil.WithWorkingDir(wd)) | |||
if err != nil { | |||
logrus.Warnf("Failed to initialize git: %v", err) | |||
if st, err := os.Stat(path.Join(wd, ".git")); err == nil && st.IsDir() { | |||
return nil, errors.New("git not found in PATH, but .git directory exists") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still a warning, not a failing error.
WARN: No git was found in the system. Current commit information was not captured by the build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice that warning is on caller side. But update the message.
build/git.go
Outdated
return | ||
} | ||
|
||
if !gitc.IsInsideWorkTree() { | ||
logrus.Warnf("Unable to determine git information") | ||
return | ||
return nil, errors.New("not inside a git repository") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an error. If no git repo then just continue.
Signed-off-by: CrazyMax <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
closes #1470
Windows drives in WSL version 2 uses the 9P protocol which the WSL instance connects to. When running git operations on a 9p fs using git from
/usr/bin/git
, it can be quite slow:But using
git.exe
is quite fast:This change will detect if git operations occur on WSL and on a 9p fs and in this case lookup for
git.exe
, otherwise fallback togit
.Signed-off-by: CrazyMax [email protected]