Conversation
|
@dra27 where is the use of check-typo (and maybe the pre-commit-hook) documented? If you have committed any documentation in the repository (I could only find a mention in passing in CONTRIBUTING.md), I think that it would be nice to have something in HACKING.adoc -- either the toplevel one, or a new tools/HACKING.adoc. |
3098fd1 to
6a7dcd0
Compare
|
@gasche - I'm slightly embarrassed to say that while it's on my TODO list, documentation beyond the mention in CONTRIBUTING is all that I've committed so far. |
|
I had started to review it! I think the changes are great, just that going through it was taking time - I'll definitely come to it when I'm back from vacation in the second week of Aug. |
|
Thanks for the update, and have nice vacations :-) |
|
(gentle ping) |
|
Would maybe someone else be interested in looking at this? @nojb, @Octachron, @trefis? |
dra27
left a comment
There was a problem hiding this comment.
Sorry for the delay reviewing this. I have reviewed very carefully the changes to .gitattributes and reckon that all the pertinent logic which was hard-coded in check-typo is now transferred to .gitattributes.
The changes to the script itself look good to me - perhaps @damiendoligez could cast a quick eye over it for any concerns about coding style?
| env $OCAML_CT_GIT_INDEX git check-attr --all $OCAML_CT_CA_FLAG "$1" \ | ||
| | grep -o " typo\\..*$" | sed "s/ typo\\.//g" \ | ||
| | grep -v ": unset" | grep -v ": false" \ | ||
| | sed "s/: set//g" | sed "s/: true//g" | sed "s/: may/?/g" |
There was a problem hiding this comment.
This pipe can be more simply (or at least compactly): sed -ne '/: \(set\|true\|may\)/s/.* typo\.//p' -e 's/: \(set\|true\)//' -e 's/:.*/?/'
There was a problem hiding this comment.
My sed-fu is not high enough to understand your version, so I'll stick with dumb pipes for now.
dra27
left a comment
There was a problem hiding this comment.
Sorry for the delay reviewing this. I have reviewed very carefully the changes to .gitattributes and reckon that all the pertinent logic which was hard-coded in check-typo is now transferred to .gitattributes.
The changes to the script itself look good to me - perhaps @damiendoligez could cast a quick eye over it for any concerns about coding style?
|
I just ran the script over the entire repo and found that the I've also pushed a commit which makes it so that This needs rebasing, so feel free to squash the first commit and potentially drop the latter commit when you do! |
54b43fd to
de2e82e
Compare
|
I rebased the PR and I'm in the process of going over the review comments. I hope to finish today to get this PR dealt with. |
|
@dra27 I'm sorry, I am just seeing that you did pushes on your own. (I force-pushed when I rebased.) I fixed the yacc-stuff as well, but I'm happy to integrate the long-line/very-long-line commit in the PR, could you push it again? |
|
No apology needed - it's your branch 🙂 Commit re-pushed... |
a5755c7 to
e28d05e
Compare
|
I believe that I should now have addressed all review comments (thanks!). |
e28d05e to
b263802
Compare
dra27
left a comment
There was a problem hiding this comment.
One tweak - though mainly a chance to use GitHub's new suggest edit feature :)
.gitattributes
Outdated
| testsuite/tests/lib-unix/win-stat/fakeclock.c typo.missing-header=false | ||
| testsuite/tests/misc-unsafe/almabench.ml typo.long-line | ||
| testsuite/tests/tool-toplevel/strings.ml typo.utf8 | ||
| testsuite/tests/typing-unboxed-types/test.ml.reference* typo.white-at-eof |
There was a problem hiding this comment.
| testsuite/tests/typing-unboxed-types/test.ml.reference* typo.white-at-eof |
|
@dra27: the way I read the diff produced by this indeed-intriguing feature, you are propose to remove the What's going on here? |
|
In the interest of not waiting too much on this issue (its discussion in #2096 (comment) bumped it up in my priority list), I'm thinking of merging this PR today or tomorrow. |
damiendoligez
left a comment
There was a problem hiding this comment.
Looks OK except for the unrelated changes.
| modules = "tscanf2_io.ml" | ||
| files = "tscanf2_slave.ml" | ||
| reference = "${test_source_directory}/reference" | ||
| files = "tscanf2_worker.ml" |
There was a problem hiding this comment.
These changes are completely unrelated to check-typo (unless you intend to add a style checker). They should be in a separate PR (and probably touch many more files).
b263802 to
2c5bde0
Compare
Before this patch, check-typo is directed by a single git attribute,
ocaml-typo, which is used as a key to set a value:
ocaml-typo=long-line,missing-header
(the value here is `long-line,missing-header`, and the code splits the
comma later)
This model is very fragile because .gitattributes does not allow to
give attribute keys a collecting/aggregating semantic: each new
setting of the key removes the previous setting, instead of adding to
them. For example,
testsuite/tests/** ocaml-typo=missing-header
testsuite/tests/win-unicode/*.ml ocaml-typo=utf8
and
testsuite/tests/win-unicode/*.ml ocaml-typo=utf8
testsuite/tests/** ocaml-typo=missing-header
are not equivalent, and instead of using either one we would introduce
redundancy for robustness:
testsuite/tests/** ocaml-typo=missing-header
testsuite/tests/win-unicode/*.ml ocaml-typo=missing-header,utf8
With this patch, we switch to a model where each ocaml-typo setting is
its own attribute, of the form `typo.<<attribute>>`. The lines above
would be written, in either order:
testsuite/tests/** typo.missing-header
testsuite/tests/win-unicode/*.ml typo.utf8
Not only does this approach make our .gitattributes more robust, it
allows for a more fine-grained treatment of the "unused-prop"
marker. This was used as an attribute to say: don't make it in an
error if the given typo-rule is in fact respected (by default, opting
out of a typo-rule gives an error if the typo-rule is respected). But
because of the single-key nature of ocaml-typo, unused-prop would
range over all settings, not just one of them. For example
emacs/caml.el ocaml-typo=long-line,unused-prop,missing-header
seems to suggest that 'unused-prop' only qualifies the 'long-line'
rule, but in fact it also ranges over 'missing-header'. In contrast,
with this patch, we write the following:
emacs/caml.el typo.long-line=may typo.missing-header
the `=may` value setting is used to make an exception to a typo-rule
optional.
Interestingly, most .gitattributes lines worked without extra error
when I turned each unused-prop in a =may setting over the rule just
before, instead of all rules: our checking is now more precise than
before, better capturing the intent of the .gitattributes author.
As I had to rewrite parts of the check-typo code for this, I took the
opportunity to rename a couple variables speaking about SVN (now long
defunct) into more meaningful names:
- `$is_svn` => `$path_in_index`
- `$svnrules` => `$attr_rules`
The initial motivation is to have a `foo.reference` file instead of `reference`.
typo.long-line can still be explicitly set in .gitattributes (and typo.long-line typo.very-long-line=may will still issue unused if no lines are more than 80 columns)
|
David Allsopp (2018/10/18 07:03 -0700):
You're right, I had! In which case, it should be `typo.prune`, but perhaps this can be simplified by altering the tests. The following files:
```
tests/typing-unboxed-types/test.ml.reference-flat
tests/typing-unboxed-types/test.ml.reference-noflat
tests/translprim/array_spec.compilers.reference.flat
tests/translprim/module_coercion.compilers.reference.flat
tests/translprim/module_coercion.compilers.reference.no-flat
tests/translprim/array_spec.compilers.reference.no-flat
```
are the only ones which don't end `.reference`. Perhaps they should
just be renamed to `.flat.reference` and `.no-flat.reference` so that
the normal prune rule comes into play?
Yes, please!
Sorry for having done things the wrong way initially!
|
|
I'm busy with other things and would like to get done with this PR. Is it possible to leave those further suggestions to future PRs? |
|
Gabriel Scherer (2018/10/18 07:25 -0700):
I'm busy with other things and would like to get done with this PR. Is
it possible to leave those further suggestions to future PRs?
Fine with me :)
|
|
@gasche just let me push a commit to rename the reference files before you merge. |
|
Done. |
|
Thanks! Merged. |
Co-authored-by: cuihtlauac <cuihtlauac@users.noreply.github.com>
I wanted this to fix this particular comment of @dra27 in the review of #1905. If the present PR is accepted, I will rebase #1905 on top of it.