Commit ef96a3a2 authored by Peter Leitzen's avatar Peter Leitzen Committed by Albert Salim

Fix `scripts/security-harness` to support older git versions

Prior this commit `scripts/security-harness` would not remove lefthook
if the git < 2.31 because the option `--path-format=absolute` wasn't
available yet and just been echoed which resulted in a multiline result:

  $ git rev-parse  --path-format=absolute --git-path hooks/pre-push
  --path-format=absolute
  .git/hooks/pre-push

The hook path "--path-format=absolute\n.git/hooks/pre-push" which does
not exist. Moreover, the first run creates a directory
"--path-format=absolute\n.git/" which is cumbersome to remove.

In this commit we only care about the last line which is most likely the
path to the hook.
parent 93fb6734
......@@ -4,7 +4,6 @@
require 'digest'
require 'fileutils'
require 'open3'
if ENV['NO_COLOR']
SHELL_RED = ''
......@@ -19,7 +18,7 @@ else
end
LEFTHOOK_GLOBAL_CONFIG_PATH = File.expand_path("../lefthook.yml", __dir__)
HOOK_PATH = Open3.capture3("git rev-parse --path-format=absolute --git-path hooks/pre-push")[0].strip
HOOK_PATH = `git rev-parse --path-format=absolute --git-path hooks/pre-push`.split.last
HOOK_DATA = <<~HOOK
#!/usr/bin/env bash
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment