Commit Graph

8 Commits

Author SHA1 Message Date
brian m. carlson
abadadaf82
tools: make strings translatable 2022-01-18 17:38:25 +00:00
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
Chris Darroch
dd8e306e31 all: update go.mod module path with explicit v2
When our go.mod file was introduced in commit
114e85c2002091eb415040923d872f8e4a4bc636 in PR #3208, the module
path chosen did not include a trailing /v2 component.  However,
the Go modules specification now advises that module paths must
have a "major version suffix" which matches the release version.

We therefore add a /v2 suffix to our module path and all its
instances in import paths.

See also https://golang.org/ref/mod#major-version-suffixes for
details regarding the Go module system's major version suffix rule.
2021-08-09 23:18:38 -07:00
brian m. carlson
8f3d9d5ef6
tools: always force a UTF-8 locale for cygpath
When we look up the repository path from Git, we pass it through cygpath
-w to canonicalize it into a Windows path, since Cygwin's Git will give
us a Unix-style path.  We perform path canonicalization not only on
Cygwin, but also on MINGW as well, which include Git Bash, since we want
to accept and canonicalize Unix-style paths there as well.

Normally, this works great.  However, if invoked not from Git Bash, but
via the Git for Windows bash.exe command, no locale is set in the
environment, despite the locale binary indicating UTF-8 locales.  As a
result, if non-ASCII character exist in the path name, it tries to
encode them in ISO-8850-1.

On a standard Unix, where paths are always bytes, defaulting to
ISO-8859-1 might be fine, because regardless of the encoding, paths are
always bytes and no encoding needs to be performed.  On macOS, where the
file system and all locales use UTF-8, this is also not a problem,
because again, no encoding needs to be done.

However, on Windows, where paths are natively stored as UTF-16, this is
remarkably unhelpful, since the majority of Unicode code points cannot
be represented in ISO-8859-1.  Thus, the vast majority of paths are
broken by cygpath when the locale is not set.

Since we know we always want UTF-8 from cygpath, let's just force that
in the environment we pass it.  We need to copy the environment since
the value we have is shared among all executed subcommands and we don't
want to modify other commands' locales, since that would cause error
messages to be printed in English instead of the user's locale.

Note that before this change, the test would fail because the local
working directory was not read, and therefore it would be empty on
Windows.
2020-09-08 19:12:02 +00:00
brian m. carlson
354c8a53d9
tools: handle missing cygpath gracefully
It looks like there are situations in which some Git for Windows
installations don't have the cygpath binary.  In that case, we end up
picking an empty string, which leads us to install hooks and LFS objects
in the current directory.  Fix this by trying cygpath, and if it fails
due to a path lookup error, returning the original path as we got it.
2019-11-25 16:11:54 +00:00
Marat Radchenko
482260c7e3 Fix error strings to follow Go guidelines
Error strings should not be capitalized (unless beginning with proper nouns or acronyms) or end with punctuation:
https://github.com/golang/go/wiki/CodeReviewComments#error-strings
2019-10-22 17:33:49 +03:00
Taylor Blau
a0c8fbe3a7 tools: rename TranslateIfCygwin to TranslateCygwinPath 2017-02-28 13:39:33 -08:00
Taylor Blau
88522b4e04 tools: wrap os.Getwd with cygwin support 2017-02-20 15:25:43 -07:00