-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
README commit hook prevents commit if only .md file changed #312
Comments
Yeah, I have experienced this too. I then follow the directions about how to commit anyway (which forces me to commit from the command line). I don't see a simple way to prevent this regrettable behaviour, while also catching the (more likely? worse?) situation of someone editing their README.md by hand, even though it's generated by README.Rmd. Do you have any ideas re: resolution? Would you prefer to have no pre-commit hook at all? |
The question is how often the README.md file gets changed without the .Rmd file. I could imagine it is often the other way round: README.Rmd file gets changed, but the user forgot to knit a new .md file. On the other hand, git directly presents a solution on how to commit anyways. So maybe it is fine to leave it as conservative as it is. |
I think we will leave it for now, as I think it's the best compromise. If you end up modifying the hook as described above for yourself, please comment here, so we can store/link it for posterity as an alternative to removing the hook. |
I think that in general convenience and safeguard functionality should not prevent me from doing stuff - it should help if helping does not harm. This functionality is harmful (I use automatic information and statistics in README.Rmd so I re-knit regularly, now I cannot because usethis tinkered with my Git-repo without actually telling me beforehand; example: https://github.com/petermeissner/ical/blob/master/README.Rmd). I think this is a very bad tradeoff - I feel patronized and a little pissed off at the moment - and I will not do as usethis suggests and work around the new problem by going to the terminal (where is the convenience in that?) but simply either re-hack whatever usethis did (if possible) or stop using usethis (which is unfortunate because it offers some very-very-very nice tooling otherwise). So please consider re-opening this issue and give back users freedom to automate stuff in their scripting language :-) - maybe a short option asking the user when For future reference: the problem can be solved by
|
Adding a pre-commit hook is quite an invasive change that could end up being more time consuming and frustrating for users, especially beginners new to git, than is justified by the potential benefits. It can be useful to be asked to rebuild the README.md if you make a change to README.Rmd and forget to do so, but I'm not sure the +s outweigh the -s. The mantra of 'do no harm' is important in life and in software and I suspect some people have been confused by this. Another way of looking at this is that it reminds me of a common critique of Microsoft products that it is 'too clever', and sometimes does things that are unhelpful. For an interesting, and quite funny, thread on this, see here! Good news: I'm sure there are various solutions out there that could help maintain the +s of the current set-up without the -s. This issue could be be a place to help identify the most appropriate, if assuming the current behaviour is not set in stone. An idea I thought of just now after following 'future reference' section at the bottom of the previous message:
There may be negatives of this suggestion I've not considered and happy to talk about them. Overall very pleased with the P.s. this is what I ran just now to be able to push an updated version of README.Rmd, in case it's of use/interest to others who're asking the same question, how do I commit my updated README,Rmd file when README.md has not changed:
|
Everywhere I work (shell, RStudio,and GitKraken), here's what happens when I trigger this hook:
80% of the time, I realize I've edited the wrong file or forgotten to re-render and am thankful. The other 20% I do exactly as the message says:
Do you not get these instructions? What interface to git do you use? Also, as you've clearly sorted out, you can delete this hook if it somehow does you more harm than good:
|
I do get those instructions and that's what I did before removing the pre-commit hook. However there are some projects where it's useful to not to have to use that solution. That could happen if README.Rmd is a manuscript that compiles to .pdf, if minor changes are frequently made to the .md document but not the .Rmd as @dirkschumacher found or in other cases, such as documented by @petermeissnerbot or when a user runs To save adding the
Would help users who didn't know that the change isn't necessarily permanent and what is going on under the hood, which has co-benefits from a learning perspective. I'm a long time R and git user and I didn't know so suspect that's most people. A good compromise? |
P.s. to answer your other question, I'm running R/RStudio on Ubuntu with |
I think it sounds like you should remove the hook in that project, since it's a net negative for you.
The pre-commit hook is messaged at creation. In theory we could add more detail. But I have found that this is no panacea because people, frankly, often don't really read messages, especially not long ones! Even if they do, they won't retain this information over the weeks or months between creating the project and the first time they bump into this. If we can keep it short (on one line) and parallel with the other messages above, I certainly am content to modify this message. I suspect this is one of those things you sort of have to bang your shins on. We could remove the git hook and then, based on my experience, I would just bang my shins on changing |
Fair point that the message does tell you where it is at creation time. Yet another option would be to provide an arguement, |
When using an
README.Rmd
where the output of chunks can change without changing the code in theRmd
file, the commit hook inusethis::use_readme_rmd
prevents the resultingREADME.md
file from being commited to git.I sometimes add coverage results into the readme during initial development of a package. When knitting the README.Rmd, often only the README.md file changes.
Below is a simple example where the
README.Rmd
file outputs a random number. The commit hook prevents adding a newREADME.md
without making a change toREADME.Rmd
.The text was updated successfully, but these errors were encountered: