Skip to content

Commit 6608fc8

Browse files
committed
Add a git_hooks_path config variable that allows you to point the package to the correct path to place githooks for your project. This is useful if your project is a git submodule of a bigger project.
1 parent c42045f commit 6608fc8

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

config/git-hooks.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,15 @@
290290
|
291291
*/
292292
'debug_commands' => false,
293+
294+
/*
295+
|--------------------------------------------------------------------------
296+
| Git hooks path
297+
|--------------------------------------------------------------------------
298+
|
299+
| This configuration option allows you to configure where the git hooks
300+
| are stored for this project, you might need to change this if you
301+
| are using git submodules as part of a wider project.
302+
*/
303+
'git_hooks_path' => base_path('.git'.DIRECTORY_SEPARATOR.'hooks'),
293304
];

src/GitHooks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ public function getHookStub()
8484
*/
8585
public function getGitHooksDir()
8686
{
87-
return base_path('.git'.DIRECTORY_SEPARATOR.'hooks');
87+
return config('git-hooks.git_hooks_path', base_path('.git'.DIRECTORY_SEPARATOR.'hooks'));
8888
}
8989
}

tests/Features/Commands/RegisterHooksTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
$this->deleteTempDirectory();
1111
});
1212

13+
1314
test('Throws exception when git was not initialized in project', function () {
1415
// delete .git folder
1516
$this->deleteTempDirectory();
@@ -53,3 +54,6 @@
5354
->toBeFile()
5455
->toContainHookArtisanCommand($hookName);
5556
})->with('registrableHookTypes');
57+
58+
59+

0 commit comments

Comments
 (0)