git-lfs/tools/cygwin_windows.go
brian m. carlson 087db1de70
Set package version to v3
Since we're about to do a v3.0.0 release, let's bump the version to v3.

Make this change automatically with the following command to avoid any
missed items:

  git grep -l github.com/git-lfs/git-lfs/v2 | \
  xargs sed -i -e 's!github.com/git-lfs/git-lfs/v2!github.com/git-lfs/git-lfs/v3!g'
2021-09-02 20:41:08 +00:00

55 lines
926 B
Go

//go:build windows
// +build windows
package tools
import (
"bytes"
"fmt"
"github.com/git-lfs/git-lfs/v3/subprocess"
)
type cygwinSupport byte
const (
cygwinStateUnknown cygwinSupport = iota
cygwinStateEnabled
cygwinStateDisabled
)
func (c cygwinSupport) Enabled() bool {
switch c {
case cygwinStateEnabled:
return true
case cygwinStateDisabled:
return false
default:
panic(fmt.Sprintf("unknown enabled state for %v", c))
}
}
var (
cygwinState cygwinSupport
)
func isCygwin() bool {
if cygwinState != cygwinStateUnknown {
return cygwinState.Enabled()
}
cmd := subprocess.ExecCommand("uname")
out, err := cmd.Output()
if err != nil {
return false
}
if bytes.Contains(out, []byte("CYGWIN")) || bytes.Contains(out, []byte("MSYS")) || bytes.Contains(out, []byte("MINGW")) {
cygwinState = cygwinStateEnabled
} else {
cygwinState = cygwinStateDisabled
}
return cygwinState.Enabled()
}