rycus86 / githooks

Githooks: per-repo and global Git hooks with version control
MIT License
382 stars 20 forks source link

Bugfix: core hookspath #67

Closed gabyx closed 4 years ago

gabyx commented 4 years ago

The path to --use-core-hookspath is not parsed and set. This is a small bug fix, with some minor cosmetics.

P.S: Where I am not sure, but nothing to this PR. After step # 4. Setup new folder if running in find_git_hook_templates I am not sure what happens if we are there and --use-core-hookspath. I think its fine. Its a bit confusing... But in another way its also clear you choose a template dir and then it gets used as the core.hooksPath...

coveralls commented 4 years ago

Pull Request Test Coverage Report for Build 488


Changes Missing Coverage Covered Lines Changed/Added Lines %
install.sh 25 38 65.79%
<!-- Total: 32 45 71.11% -->
Files with Coverage Reduction New Missed Lines %
cli.sh 17 88.08%
<!-- Total: 17 -->
Totals Coverage Status
Change from base Build 487: -1.2%
Covered Lines: 1826
Relevant Lines: 2108

💛 - Coveralls
gabyx commented 4 years ago

Lets test.

gabyx commented 4 years ago

All test pass.

rycus86 commented 4 years ago

I'll check this PR later today. Thanks!

rycus86 commented 4 years ago

Hm, I'm a bit confused about this PR, what is the fix actually in here? I see that you rewrote a bunch of ifs and return statements (most of which I disagree with :) ), changed some braces around variable names, but the logic doesn't seem to change.

If there is a bug, could you please have the PR fix that only? If you'd like to discuss those code style/program flow changes, I'm open to it, but let's talk about them on an issue maybe first (maybe a PR is better to comment on the code itself), but the important thing is that we make that issue/PR about the styling changes, not the bugfix - hope that sounds OK?

gabyx commented 4 years ago

Clear. Was a bit frustrated, with bash and IMO strange code flow latetly ... I comitted only the relevant stuff.

The bug fixes is in install.sh

Feel free to incorporate what you think is valuable I came across this when trying to experiment with install.sh in a script on the server... And I had also some mess with the state and such...

rycus86 commented 4 years ago

Sure, no probs and thanks for the changes! I'll have another look at this shortly.

gabyx commented 4 years ago

Ok, now its correct.

gabyx commented 4 years ago

Wua, thats hard to grasp controlflow, damm, now its better. :-|

gabyx commented 4 years ago

@rycus86 : I added a test 112 which is simple. It does currently not work on master, but it should in my opinion. Are you not also the opinion, that my changes (not much) might go into the right direction? At least it fixes the test. Also I checked again: Reaching step 4 with --use-core-hookspath is also perfectly fine. # 4. Setup new folder if running interactively and no folder is found by now. Maybe you have some time to have a look.

I would also suggest to have one place to call set_githooks_directory (I left that intentionally out) by distinguising between --use-core-hookspath and not... instead of three places, also deep down the callstack ;-).

rycus86 commented 4 years ago

Thanks for the test! I left some comments on it, that it looks like it's more a test setup issue rather than an install script issue. Still, I don't quite get why are there corePath related changes in this PR if the problem is with the template directory? (if I understand correctly)

rycus86 commented 4 years ago

For this one

$ sh -c "$(curl -fsSL https://r.viktoradam.net/githooks)" -- --use-core-hookspath /home/public/.githooks does not work -> Fixed it. L3501

I see what you mean now. It feels like a much cheaper fix would be:

rycus86 commented 4 years ago

What do you meant by this, sorry? (I think line numbers have got messed up)

L3686, which is not right. (according to the function what it should do)

rycus86 commented 4 years ago

Please check out https://github.com/rycus86/githooks/pull/69 , I think this is not actually an issue, but the README was quite misleading on the parameter usage.

gabyx commented 4 years ago

One question: When a valid existing init.tempalteDir is set but no hooks subdirectory. A normal installation should work with out specifying --template-dir. (shouldn't it?)

I will update accordint to the PR #69 .

rycus86 commented 4 years ago

In that case, you template dir might not have been valid, and I think the installer will continue trying the default location in /usr/..., then offer to search for it, then offer to create one (by default at ~/.githooks/templates (no hooks subfolder in this one).

Sorry about the back and forth in this PR, I couldn't remember these things until I started writing those tests last night, then ot clicked that it should be working, only the README is wrong.

gabyx commented 4 years ago

Closed in favor of a new one, to restart again.