Repository navigation
Config include exclude - #1257
Conversation
|
As a side note, the For now, I think this is fine, as I assume it will be a pretty drawn-out process to preform this refactor, since so many parts of LFS depend on this type. /cc @sinbad |
There was a problem hiding this comment.
I actually think this function was better where it was; it's specifically about converting string arguments to slices or defaulting and so belongs firmly unexported in command in my view. I don't see any benefit in promoting it to an exported function in Configuration, doing so widens that scope outside its remit IMO (which I think you were feeling too based on your follow up comment).
|
👍 except for packaging comments |
|
Oh, should have a test too. |
f48ab26 to
190789f
Compare
|
@sinbad great points. I was definitely feeling the weight of |
0052443 to
190789f
Compare
190789f to
02236d2
Compare
|
Looks like the |
|
Sorry, I should have been more specific: there's a test for the |
| // | ||
| // NOTE: this method should only be called during testing. | ||
| func NewFromValues(gitconfig map[string]string) *Configuration { | ||
| config := &Configuration{ |
There was a problem hiding this comment.
You could actually put this in config_test.go to enforce the 'only testing' requirement.
There was a problem hiding this comment.
Originally this func was in the config_test.go file, but I needed to use it in the commands_test.go. This is sort of smelly to me, but I'm not quite sure what to do about it.
|
Looks good to me, the prune failure is puzzling (auth error), I re-ran the test to be sure it wasn't just an intermittent thing but it happened again. |
|
@sinbad yeah, not sure what's up with the prune failure, either. @technoweenie and I re-ran the tests in #1267 and the failures were intermittent, so you may have just gotten unlucky. Thoughts on moving OS X |
Backport #1257 for v1.2.x: Config include exclude
In commit b7e4910 of our "main" development branch and commit 779d7a3 of our "release-3.7" branch, when we expanded our tests of the "git lfs checkout" and "git lfs pull" commands, we also corrected a typo in the initial "pull" test in our t/t-pull.sh test script. Specifically, we fixed a call to our refute_server_object() assertion where ever since commit 7158e3b of PR git-lfs#2641 we had accidentally passed the name of a nonexistent variable as the second parameter. As a result, an empty string was passed for the Git LFS object ID the assertion was supposed to verify did not exist in the test server's storage. Since the server then responded with an error, the assertion concluded the object did not exist on the server, and incorrectly allowed the test to continue and ultimately pass. We have two other similar assertion functions, the refute_local_object() and refute_remote_object() functions, both of which also incorrectly succeed when passed empty or invalid Git LFS object IDs. Both functions simply check that no file exists at a location whose path is derived from the given object ID, which is virtually always going to be the case when an invalid ID is provided as a parameter. To ensure that all three assertions allow only valid object IDs, we introduce an is_valid_oid() function which checks that its single "oid" parameter matches the format of all the SHA-256 hashes generated by the Git LFS client, i.e., a 64-character string consisting of only lowercase ASCII letters and the digits zero through nine. We then call the new is_valid_oid() function in each of our three refute_*_object() assertions and pass their "oid" parameters before they proceed to using those parameters in their normal checks. With this change, we should prevent any future regressions in our shell test suite where we accidentally pass empty or invalid object IDs to these assertions. Note that we do not need to call the is_valid_oid() function in our various "positive" assertion functions like the assert_local_object() or assert_server_object() functions because they can only succeed when the given Git LFS object ID actually corresponds to an object file in the appropriate storage location. We also adjust two of our test helper functions so that they also verify their object ID parameters, even though these functions are not assertions per se. In the corrupt_local_object() helper function, which overwrites an object file in the local storage directories, we add a check that the file actually exists before we alter its contents. This is sufficient to ensure that the function will fail if it is passed an empty or invalid "oid" parameter, so we do not need to call our new is_valid_oid() function. Likewise, we do not need to call the is_valid_oid() function in our delete_local_object() helper function because it already will fail if the object file it intends to remove does not exist. This is the case because we invoke the rm(1) command on the file but do not pass the -f option. We therefore add a comment to note that if we ever change the function passes the -f option to the rm(1) command, we should then also add a preliminary check that the object file exists. Unlike the delete_local_object() helper function, however, at present the delete_server_object() function will succeed even if it is passed an empty or invalid "oid" parameter. The function makes a "DELETE" HTTP request to the test server, whose lfsDeleteHandler() function always returns a 200 status code even if the object ID extracted from the request URL does not correspond to an entry in the in-memory set of object data retained by the server. Hence we add a call to our new is_valid_oid() function in the delete_local_object() function to guard against a caller passing an empty or invalid "oid" parameter. Finally, we correct one invocation of the refute_server_object() assertion where we currently only pass an object ID parameter without a preceding repository name parameter, because otherwise the "init fetch unclean paths" test in the t/t-fetch-paths.sh test script will now fail. This oversight was first introduced when the predecessor version of the test, the "fetch include/exclude with unclean paths" test, was originally added to the former test/test-fetch.sh script in commit 9e0a30a of PR git-lfs#1257. Co-authored-by: Lars Schneider <[email protected]>
@dipnlik reported #1251 the other day that the include/exclude filters made a distinction between
./foo/bar/(with the trailing slash) and./foo/bar(without).This pull-request introduces a patch that essentially runs filepath.Clean() against the paths before processing them. In addition, it removes the
command.determineIncludeExcludeFiltersfunction, and instead introduces a set of more granular replacement functions in theconfig.Configurationtype. Those functions are all documented within the changeset.