| 1 | package toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/" |
| 5 | "osscip-go gomod github.com/golang/go/src go1.25.0 os/" |
| 6 | "os/execscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/" |
| 7 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 8 | |
| 9 | "github.com/git-lfs/git-lfs/v3/subprocessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/" |
| 10 | "github.com/git-lfs/git-lfs/v3/trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/" |
| 11 | "github.com/pkg/errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/" |
| 12 | ) |
| 13 | |
| 14 | func Getwdscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/Getwd().() (dir string, err error) { |
| 15 | dir, err = osscip-go gomod github.com/golang/go/src go1.25.0 os/.Getwdscip-go gomod github.com/golang/go/src go1.25.0 os/Getwd().() |
| 16 | if err != nil { |
| 17 | return |
| 18 | } |
| 19 | |
| 20 | if isCygwinscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/isCygwin().() { |
| 21 | dir, err = translateCygwinPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/translateCygwinPath().(dir) |
| 22 | if err != nil { |
| 23 | return "", errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.Wrapscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/Wrap().(err, trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("error converting working directory to Cygwin")) |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | return |
| 28 | } |
| 29 | |
| 30 | func translateCygwinPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/translateCygwinPath().(path string) (string, error) { |
| 31 | cmd, err := subprocessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/.ExecCommandscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/ExecCommand().("cygpath", "-w", path) |
| 32 | if err != nil { |
| 33 | // If cygpath doesn't exist, that's okay: just return the paths |
| 34 | // as we got it. |
| 35 | return path, nil |
| 36 | } |
| 37 | // cygpath uses ISO-8850-1 as the default encoding if the locale is not |
| 38 | // set, resulting in breakage, since we want a UTF-8 path. |
| 39 | env := make([]string, 0, len(cmd.Envscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/Cmd#Env.)+1) |
| 40 | for _, val := range cmd.Envscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/Cmd#Env. { |
| 41 | if !stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(val, "LC_ALL=") { |
| 42 | env = append(env, val) |
| 43 | } |
| 44 | } |
| 45 | cmd.Envscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/Cmd#Env. = append(env, "LC_ALL=C.UTF-8") |
| 46 | buf := &bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#{} |
| 47 | cmd.Stderrscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/Cmd#Stderr. = buf |
| 48 | out, err := cmd.Outputscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/Cmd#Output().() |
| 49 | output := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.25.0 strings/TrimSpace().(string(out)) |
| 50 | if err != nil { |
| 51 | // If cygpath doesn't exist, that's okay: just return the paths |
| 52 | // as we got it. |
| 53 | if _, ok := err.(*execscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/.Errorscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/Error#); ok { |
| 54 | return path, nil |
| 55 | } |
| 56 | return path, errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.Newscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("failed to translate path from Cygwin to Windows: %s", buf.Stringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#String().())) |
| 57 | } |
| 58 | return output, nil |
| 59 | } |
| 60 | |
| 61 | func TranslateCygwinPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TranslateCygwinPath().(path string) (string, error) { |
| 62 | if isCygwinscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/isCygwin().() { |
| 63 | var err error |
| 64 | |
| 65 | path, err = translateCygwinPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/translateCygwinPath().(path) |
| 66 | if err != nil { |
| 67 | return "", err |
| 68 | } |
| 69 | } |
| 70 | return path, nil |
| 71 | } |