Skip to content

fix: create hooks dir, when hooks dir not exists #5

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

Merged
merged 4 commits into from
Jun 7, 2017

Conversation

liujingyu
Copy link

create .git/hooks dir, when .git/hooks dir is not exists.

@BrainMaestro
Copy link
Owner

Hey, this is pretty useful. Thanks

$hookDir = "{$gitDir}/hooks";

if (! is_dir($hookDir)) {
mkdir($hookDir);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would fail if the gitDir folder does not already exist. We need to make the mkdir recursive. Do you mind fixing that? You can get more info here. Or you can look at how the git hooks folders were created in the AddCommand and UpdateCommand tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

src/Hook.php Outdated
@@ -22,10 +22,19 @@ public static function getValidHooks()
);
$validHooks = [];

//add customize hooks
$customizeHooks = isset($json['extra']['customize_hooks']) ?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to define some hooks except applypatch-msg,commit-msg and so on. eg: ctags hook order to read source code.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how will you integrate the custom hooks into git?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My git config:

[alias]
    st = status
     .....
    # this line
    ctags = !.git/hooks/ctags   

i can git ctags in the my project.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, while that's great, it's not technically a git hook. It's a script that you're aliasing to a git command. So, it's not really in the scope of this project. Don't you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. This project is order to create some scripts for git, some scripts been known as git hooks. So, i think it can add custom hooks. Thanks.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, git hooks are more than just scripts. They are tied into git's event system and run only when an event occurs, so custom ones don't really make sense. A read about git hooks.

Anyway, I would appreciate it if you could remove that commit for now, since it's not really tied to the original feature you were implementing. Then I can merge, and we can talk about the custom hooks in a separate PR. Thanks

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i revert that commit.

mark and others added 2 commits June 7, 2017 08:47
@BrainMaestro BrainMaestro merged commit bad5278 into BrainMaestro:master Jun 7, 2017
@BrainMaestro
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants