diff --git a/githooks/cmd/common/checks.go b/githooks/cmd/common/checks.go index 72702731..172e53e4 100644 --- a/githooks/cmd/common/checks.go +++ b/githooks/cmd/common/checks.go @@ -45,7 +45,7 @@ func CheckGithooksSetup(log cm.ILogContext, gitx *git.Context) { gitDir, err := gitx.GetGitDirCommon() log.AssertNoErrorF(err, "Could not determine common Git dir.") - hasRunWrappers, _ := cm.IsPathExisting(path.Join(gitDir, "githooks-contains-run-wrappers")) + hasRunWrappers, _ := cm.IsPathExisting(path.Join(gitDir, "hooks", hooks.RunWrapperMarkerFileName)) if hasHooksConfigured && !localCoreHooksPathSet && !globalCoreHooksPathSet && diff --git a/githooks/cmd/common/install/wrappers.go b/githooks/cmd/common/install/wrappers.go index d852ff3e..9b201f32 100644 --- a/githooks/cmd/common/install/wrappers.go +++ b/githooks/cmd/common/install/wrappers.go @@ -47,7 +47,7 @@ func InstallIntoRepo( // a link `core.hooksPath`. // We switch to run-wrappers if we install a set of maintained hooks. // or repository settings have maintained hooks set. - installRunWrappers, _ := cm.IsPathExisting(path.Join(hooksDir, "githooks-contains-run-wrappers")) + installRunWrappers, _ := cm.IsPathExisting(path.Join(hooksDir, hooks.RunWrapperMarkerFileName)) log.DebugF("Marker file for run-wrappers detected: '%v'.", installRunWrappers) installRunWrappers = installRunWrappers || hookNames != nil @@ -197,7 +197,7 @@ func UninstallFromRepo( // We always uninstall run-wrappers if any are existing. // Also reinstalls LFS hooks. - // No need to check the marker file `.githooks-contains-run-wrappers`. + // No need to check the marker file `RunWrapperMarkerFileName`. nLfsCount, err = hooks.UninstallRunWrappers(hooksDir, lfsHooksCache) log.InfoF("Githooks has reinstalled '%v' LFS hooks into '%s'.", nLfsCount, hooksDir) diff --git a/githooks/hooks/wrapper.go b/githooks/hooks/wrapper.go index 3fa8e36b..2de7c358 100644 --- a/githooks/hooks/wrapper.go +++ b/githooks/hooks/wrapper.go @@ -12,6 +12,7 @@ import ( strs "github.com/gabyx/githooks/githooks/strings" ) +var RunWrapperMarkerFileName = "githooks-contains-run-wrappers" var runWrapperDetectionRegex = regexp.MustCompile(`https://github\.com/(gabyx|rycus86)/githooks`) // IsRunWrapper answers the question if `filePath` @@ -321,7 +322,7 @@ func InstallRunWrappers( } } - err = cm.TouchFile(path.Join(dir, "githooks-contains-run-wrappers"), true) + err = cm.TouchFile(path.Join(dir, RunWrapperMarkerFileName), true) if err != nil { err = cm.CombineErrors(err, cm.ErrorF("Could not create marker that directory '%s' contains run-wrappers.", dir)) @@ -389,7 +390,7 @@ func uninstallRunWrappers( } } - _ = os.Remove(path.Join(dir, "githooks-contains-run-wrappers")) + _ = os.Remove(path.Join(dir, RunWrapperMarkerFileName)) return }