-
Notifications
You must be signed in to change notification settings - Fork 220
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
Create .git/hooks directory when it does not exist #169
Conversation
969555c
to
c5dcd9c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You added check for git hooks uninstall. But what about installing?
Lines 97 to 111 in 04f9b56
pathToFile := filepath.Join(getGitHooksDir(), hookName) | |
if yes, _ := afero.Exists(fs, pathToFile); yes { | |
if isLefthookFile(pathToFile) { | |
e := fs.Remove(pathToFile) | |
check(e) | |
} else { | |
if yes, _ := afero.Exists(fs, pathToFile+".old"); yes { | |
panic("Can`t rename " + hookName + " to " + hookName + ".old File already exists") | |
} | |
e := fs.Rename(pathToFile, pathToFile+".old") | |
log.Println("Existed " + hookName + " hook renamed to " + hookName + ".old") | |
check(e) | |
} | |
} |
When lefthook is initialized, it calls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so counter-intuitive!
Btw, Travis is failing. |
9c9ae6d
to
ec415bc
Compare
fixed |
3da9885
to
ea4386e
Compare
if (err != nil) { | ||
log.Println("⚠️ ", au.Bold(".git/hooks"), "directory does not exist, creating") | ||
|
||
if err := os.MkdirAll(hooksPath, os.ModePerm); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope we will change it back to os.Mkdir
while fixing #90
Sometimes
.git/hooks
directory does not exist and lefthook fails to init hooks. The solution is to create the directory when it does not exist.Closes #158.