mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 09:17:49 +08:00
gitutil: check git bash env when testing
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
fb2c62a038
commit
703c765ec8
@ -1,11 +1,28 @@
|
|||||||
package gitutil
|
package gitutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSanitizePathWindows(t *testing.T) {
|
func TestSanitizePathWindows(t *testing.T) {
|
||||||
assert.Equal(t, "C:\\Users\\foobar", SanitizePath("C:/Users/foobar"))
|
expected := "C:\\Users\\foobar"
|
||||||
|
if isGitBash() {
|
||||||
|
expected = "C:/Users/foobar"
|
||||||
|
}
|
||||||
|
assert.Equal(t, expected, SanitizePath("C:/Users/foobar"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func isGitBash() bool {
|
||||||
|
// The MSYSTEM environment variable is used in MSYS2 environments,
|
||||||
|
// including Git Bash, to select the active environment. This variable
|
||||||
|
// dictates the environment in which the shell operates, influencing
|
||||||
|
// factors like the path prefixes, default compilers, and system libraries
|
||||||
|
// used: https://www.msys2.org/docs/environments/
|
||||||
|
if _, ok := os.LookupEnv("MSYSTEM"); ok {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user