Commit Graph

18 Commits

Author SHA1 Message Date
Chris Darroch
04abbd8436 make additional message strings translatable
Following on from the changes in PR #4781, we can make
additional message strings translatable using the
tr.Tr.Get() method.

Because this method performs printf(3)-style format string
parsing and interpolation, we can simplify some of the
surrounding calls, e.g., from fmt.Errorf() to errors.New(),
and from fmt.Fprintf() to fmt.Fprintln().  This ensures
that if either the translated text or any interpolated
arguments happen to contain character sequences that would
be interpreted as Go format specifiers (e.g., "%s" or "%d"),
these will not result in warnings such as "%!s(MISSING)"
in the output text.

Note also that we try to remove newlines from the message
strings were possible and change the surrounding calls to
append them instead, e.g., with fmt.Fprintln().
2022-01-29 22:36:19 -08:00
Chris Darroch
2830d39ef4 avoid extra message format parsing where possible
Because the tr.Tr.Get() family of methods insert arguments
into printf(3)-style format strings after translating the
format string, we can in a few cases drop a surrounding call
to fmt.Sprintf() or a similar method, as those now take no
arguments and so are redundant.

Moreover, this will help us avoid situations where either
the translated string or the argument values interpolated
by tr.Tr.Get() produce an output string which itself happens
to contain character sequences that resemble Go format
specifiers (e.g., "%s", "%d", etc.)  In such cases passing the
string at runtime to a method such as fmt.Fprintf() will result
in the output containing a warning such as "%!s(MISSING)", which
is not ideal.

Note that in one case, in lfs/attribute.go, we can now also
simplify the format string to use standard format specifiers
instead of double-escaped ones (e.g., "%%q") since we can just
allow tr.Tr.Get() to do the interpolation.

We also take the opportunity to remove explicit leading or
trailing newlines from translation messages wherever it is
possible to convert the surrounding call to fmt.Print(),
fmt.Fprint(), fmt.Println(), or fmt.Fprintln().

Finally, in the commands/run.go file, we can replace two calls
to fmt.Fprintf() with fmt.Println() because they are just
printing output to os.Stdout, not os.Stderr, and in the
lfs/extension.go file, we can make better use of fmt.Errorf().

Note that at least one of these messages is not yet actually
passed as a translation string, but we will address that issue
in a subsequent commit.
2022-01-29 22:32:58 -08:00
Chris Darroch
0f2f1cdd9f lfs*,locking,tq: revise ancillary error messages
We rephrase some error message strings which are used when
wrapping other errors so they are clearer and more consistent
with other messages.  Note that these strings will be
prepended to the wrapper errors' messages.

In the lfs/diff_index_scanner.go file in particular we
rephrase the additional message to include a full Git
command ("git diff-index"), which is similar to how errors
are reported in the git package.
2022-01-29 22:00:41 -08:00
brian m. carlson
17d756b780
lfs: make strings translatable 2022-01-18 17:05:02 +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
228e31fb20
status: update index before showing status
When running `git lfs status`, we perform a `git diff-index`.  However,
we don't update the index first, so any changes, such as permissions
changes due to locking, cause the file to be listed as modified.  Since
these changes don't represent actual changes that we're interested in,
refresh the index before running diff-index so that it doesn't produce
spurious output.
2019-11-18 20:37:52 +00:00
Lars Schneider
cddf98f88f move git diff-index invocation to git package using gitBuffered
Git is called with the LFS filter here.
No functional changes are intended.
2017-08-22 19:34:29 +02:00
Taylor Blau
7f9cbbee67 lfs: make DiffIndexStatus implement fmt.Formatter 2017-03-16 15:23:21 -06:00
Taylor Blau
e16214c6a1 lfs: include a legend for parsing the output from diff-index 2017-03-16 10:03:32 -06:00
Taylor Blau
f09d9b0f10 lfs: don't wrap errors with 'diff-index:' prefix 2017-03-16 09:44:10 -06:00
Taylor Blau
a289d7f647 lfs: typos 2017-03-16 09:42:42 -06:00
Taylor Blau
42407fb918 lfs: don't re-wrap nil errors 2017-03-15 14:59:43 -06:00
Taylor Blau
a1b19cc560 lfs: re-wrap errors from DiffIndexScanner.Scan() 2017-03-15 14:43:09 -06:00
Taylor Blau
ce358305e6 lfs: don't return *wrappedCmd from NewDiffIndexScanner() 2017-03-15 14:41:50 -06:00
Taylor Blau
f435f1fa62 lfs: rename 'Status' to 'DiffIndexStatus'
$ gorename -from '"github.com/git-lfs/git-lfs/lfs".Status' -to DiffIndexStatus
2017-03-15 14:40:01 -06:00
Taylor Blau
b66a106915 lfs/diff_index_scanner: add documentation 2017-03-15 12:17:53 -06:00
Taylor Blau
c9871c4b93 lfs: introduce DiffIndexScanner 2017-03-14 21:50:38 -06:00