Commit Graph

64 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
brian m. carlson
22a7fbdb4a
filepathfilter: switch to strict pattern matching
There are two types of pattern matching with wildmatch patterns in Git:
gitignore and gitattributes patterns.  We'd like to support both, but
without the lazy matching that was the cause of so many problems before.

Add a type of pattern to use when creating a new filepathfilter and use
it to instantiate the wildmatch pattern with the proper flags.  Remove
the dirs flag, which is unused and has been for sometime, and also the
stripping of trailing slashes, which we want to use to indicate a
directory.  Drop the non-strict mode since our pattern matching is now
much improved and compatible with Git.
2021-08-26 15:48:54 +00:00
brian m. carlson
7cc4bce5e4
Bump wildmatch to v2.0.1
Now that we have a fully Git-compatible wildmatch, let's use it in Git
LFS.  Vendor the module appropriately.
2021-08-26 15:48:54 +00:00
brian m. carlson
fecaf2da30
filepathfilter: add an option for stricter matching
For backwards compatibility reasons, we transform some wildmatch
patterns.  However, when we're reading a pattern from .gitattributes, we
do this as well, and these transformations can cause us to fail to match
some things that Git does match.

While we want to retain the behavior of the command-line options for
compatibility, at least until 3.0, there's no reason for us to mismatch
patterns in .gitattributes: that's clearly a bug.  Let's add an option
to our pattern constructor to match patterns strictly so we can enable
it when reading from .gitattributes, and disable our pattern
manipulation when it's enabled.

To help us improve debugging, let's also add the value of the strictness
flag when printing the transformed pattern.
2020-11-10 22:59:33 +00:00
brian m. carlson
4dc476f286
locking: don't assume files are lockable if no patterns exist
Whenever we use a file path filter and there are no included patterns,
we default to assuming the files match.  For many cases, this is fine,
but this is not useful for checking whether a file is lockable: if no
files are listed as lockable, then no files are lockable.

Let's add an option for our filters to specify the default value if no
patterns match.  If that default is false, like it should be for
locking, then skip traversing the exclude patterns altogether, since
anything that's not included cannot change the result.  We test both the
case that lockable patterns are present and absent in our test.
2020-06-29 16:35:26 +00:00
brian m. carlson
3de52d4037
filepathfilter: don't say file is both accepted and rejected
The file path filter can mark a file as either accepted or rejected.
However, one of the messages that says that a file was rejected is in
the main code path, and is therefore always executed, even if the file
is actually accepted.  This leads to contradictory messages and noisier
output.

Ensure that we indicate that a file is rejected by the filter only if it
is indeed rejected; otherwise, say only that it is accepted.
2018-11-02 18:40:15 +00:00
Taylor Blau
296e8987cb filepathfilter: test correct set of global wildcards 2018-02-27 16:38:08 -08:00
Taylor Blau
2a17ee5c78 filepathfilter: do not use "assume" 2018-02-26 16:16:40 -08:00
Taylor Blau
014fd60164 filepathfilter: no longer special-case *.* 2018-02-26 16:11:36 -08:00
Taylor Blau
4fb239c74e filepathfilter: remove filepath seaprator from pattern subjects 2018-02-26 16:01:26 -08:00
Taylor Blau
c48f817844 filepathfilter: rename 'matched' to 'included' 2018-02-26 15:58:32 -08:00
Taylor Blau
e8009e1ade filepathfilter: use tracerx to print information about pattern matching 2018-02-15 15:52:32 -08:00
Taylor Blau
da86a43901 filepathfilter: assume that paths are in POSIX form 2018-02-15 15:50:20 -08:00
Taylor Blau
9e207ed5b4 filepath: remaining test cases 2018-02-15 15:50:20 -08:00
Taylor Blau
b2eac6ff62 filepath: rewrite more legacy patterns in terms of wildmatch 2018-02-15 15:50:20 -08:00
Taylor Blau
3648b19f1d filepathfilter: rewrite existing wildcard patterns 2018-02-15 15:50:20 -08:00
Taylor Blau
c847f54a51 filepathfilter: don't chomp through to basepath 2018-02-15 15:50:19 -08:00
Taylor Blau
f54531aaa4 filepathfilter: remove 'HasPrefix' from interface 2018-02-15 15:50:19 -08:00
Taylor Blau
2f37dbfacd filepath: support legacy wildcard behavior 2018-02-15 15:50:19 -08:00
Taylor Blau
629a935bad filepathfilter: implement in terms of wildmatch 2018-02-15 15:50:19 -08:00
Taylor Blau
af80061310 filepathfilter: remove outdated benchmark 2018-02-15 15:50:19 -08:00
Taylor Blau
529dc7acfa filepathfilter: remove support for 'AllowsPattern' 2018-02-07 16:58:18 -08:00
rick olson
691f00560a filepathfilter: convert paths on windows 2017-11-20 15:55:12 -07:00
rick olson
136f4b00e4 filepathfilter: Correctly implement fmt.Stringer on *noOpMatcher 2017-11-17 09:29:43 -07:00
rick olson
b31dc82461 filepathfilter: treat '*.*' as wildcard, simplify '*' pattern matching 2017-11-17 09:23:37 -07:00
rick olson
806742a625 filepathfilter: update patternMatch assertions to test multiple files 2017-11-17 09:15:23 -07:00
Taylor Blau
ed34149069 filepathfilter: un-comment tests that work with new code 2017-09-13 17:11:07 -04:00
rick olson
1cb1ba1c25 more comprehensive filepathfilter HasPrefix tests 2017-09-13 12:01:24 -06:00
Taylor Blau
8c30f31490 filepathfilter: platform-specific tests 2017-08-08 11:10:26 -06:00
Taylor Blau
18fe195047 filepathfilter: test filter's 'HasPrefix' method 2017-08-08 10:48:06 -06:00
Taylor Blau
1fa8d021f8 filepathfilter: teach 'HasPrefix' to *Filter type 2017-08-08 10:48:06 -06:00
Taylor Blau
3e8ab9bdc5 filepathfilter: teach 'HasPrefix' to Pattern interface 2017-08-08 10:48:06 -06:00
Taylor Blau
266296eb5c filepathfilter: return include/exclude patterns via Include(), Exclude() 2017-06-23 12:05:46 -06:00
Taylor Blau
289d129627 filepathfilter: replace only on Windows 2017-06-20 22:05:54 -06:00
Taylor Blau
53c61ea314 filepathfilter: _really_ clean expected pattern 2017-06-20 21:18:44 -06:00
Taylor Blau
d9871a52f9 filepathfilter: clean expected pattern before comparison 2017-06-20 20:47:15 -06:00
Taylor Blau
4fd9839208 filepathfilter: normalize pattern result on Windows 2017-06-20 20:28:49 -06:00
Taylor Blau
f465ae4f83 filepathfilter: teach AllowsPattern, to return the pattern that matched 2017-06-20 20:25:03 -06:00
Taylor Blau
f7ab3c3ef3 filepathfilter: add String() to Pattern interface 2017-06-20 17:29:24 -06:00
Taylor Blau
158b2c6b76 filepathfilter: implement String() on noOpMatcher 2017-06-20 17:29:24 -06:00
Taylor Blau
59d7f38f83 filepathfilter: implement String() on *doubleWildcardPattern 2017-06-20 17:29:24 -06:00
Taylor Blau
11d6b40a8d filepathfilter: implement String() on *pathlessWildcardPattern 2017-06-20 17:29:23 -06:00
Taylor Blau
0651b22936 filepathfilter: implement String() on *pathPrefixPattern 2017-06-20 17:29:23 -06:00
Taylor Blau
170a74f991 filepathfilter: implement String() on *simpleExtPattern 2017-06-20 17:25:19 -06:00
Taylor Blau
f2c9927f6a filepathfilter: implement String() on *pathPattern 2017-06-20 17:25:01 -06:00
risk danger olson
27ed34fa53 filepathfilter: prefer simple string matches over filepath.Match() 2017-05-18 11:29:25 -06:00
risk danger olson
ecf23ea343 filepathfilter: handle prefix matches like '/foo' 2017-05-18 11:27:04 -06:00
risk danger olson
9ea035dfa5 filetools: benchmark the patterns separately from the filters 2017-05-18 10:11:18 -06:00
risk danger olson
4a89a9732d better assertion helpers 2017-05-18 08:04:53 -06:00
risk danger olson
5e3375d991 filepathfilter: optimize simple extension patterns 2017-05-18 07:16:10 -06:00