Skip to content

Commit 6d64e09

Browse files
Skip install on /dev/null core.hooksPath
1 parent 6ca30db commit 6d64e09

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

exec/installer.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ func (i *Installer) EnableBackup(backup bool) {
5151
}
5252

5353
func (i *Installer) Run() error {
54+
if i.skipInstall() {
55+
return nil
56+
}
5457
hooks := i.getHooksToInstall()
5558

5659
// do some sort magic because go range random is weird
@@ -273,6 +276,20 @@ func (i *Installer) checkForBrokenSymlink(hook string) error {
273276
return nil
274277
}
275278

279+
func (i *Installer) skipInstall() bool {
280+
hooksPath := i.repo.HooksDir()
281+
if (hooksPath == "/dev/null") || (hooksPath == "NUL") {
282+
i.appIO.Write(
283+
fmt.Sprintf(
284+
"<warning>can't install hooks to %s please check your 'core.hooksPath' config</warning>", hooksPath),
285+
true,
286+
io.NORMAL,
287+
)
288+
return true
289+
}
290+
return false
291+
}
292+
276293
func NewInstaller(appIO io.IO, config *configuration.Configuration, repo git.Repo) *Installer {
277294
return &Installer{
278295
appIO: appIO,

0 commit comments

Comments
 (0)