set_git_hooks_dir 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/rubygems_plugin.rb +8 -0
- data/lib/set_git_hooks_dir.rb +27 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e49ae5c4f027cbc1c23c8405d985ae0feed985c2f9fec2167868ce499ce4d8bf
|
4
|
+
data.tar.gz: 45c656701813e7dcdcd6ae4a09284edfed3e21c142b2717abbbedd2b03e6a7e0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b7853d5ded97579cccc8fd293d8fed8ed508f79d7a8d8256026c603c89cf15a3c0997a42556315f35ce6f3c6f76f4ab1c01f0a92b7edcdaa7994aad97557d484
|
7
|
+
data.tar.gz: 22f8b64ce549c3186afd7359a538649292a51ad013119b11a3815a9001ddcd11a642d5efd4362dcaf71e546a17b102f38f7284d0d4ed8c49dbcb62cb0622f054
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
class SetGitHooksDir
|
6
|
+
class << self
|
7
|
+
SKIP_ENV_VARS = %w[SET_GIT_HOOKS_DIR_SKIP GITHUB_ACTION CI JENKINS_URL].freeze
|
8
|
+
|
9
|
+
def setup(hooks_dir)
|
10
|
+
return if SKIP_ENV_VARS.lazy.filter_map { |n| ENV[n] }.any? { |v| !v.empty? }
|
11
|
+
|
12
|
+
hooks_dir = Pathname.new hooks_dir
|
13
|
+
cwd = Pathname.pwd
|
14
|
+
dotgit = cwd.ascend
|
15
|
+
.filter_map { |dir| dir + '.git' if (dir + hooks_dir).directory? }
|
16
|
+
.find { |dotgit| dotgit.exist? }
|
17
|
+
|
18
|
+
raise StandardError.new("Git hooks directory #{hooks_dir} was not found at any root of GitHub repository in #{cwd}") unless dotgit
|
19
|
+
return if dotgit.directory? && File.read(dotgit + 'config').include?("\n\thooksPath = ")
|
20
|
+
|
21
|
+
git = ENV['SET_GIT_HOOKS_DIR_GIT']
|
22
|
+
git = 'git' if git.nil? || git.empty?
|
23
|
+
out = `#{git} config core.hooksPath #{hooks_dir}`
|
24
|
+
raise StandardError.new("`#{git} config core.hooksPath #{hooks_dir}` failed with status #{$?.exitstatus}: #{out}") unless $?.success?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: set_git_hooks_dir
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- rhysd
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-06-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: set_git_hooks_dir is a deadly simple gem to configure your Git hooks
|
14
|
+
on package installation
|
15
|
+
email: lin90162@yahoo.co.jp
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/rubygems_plugin.rb
|
21
|
+
- lib/set_git_hooks_dir.rb
|
22
|
+
homepage: https://rubygems.org/gems/set_git_hooks_dir
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '2.6'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubygems_version: 3.5.11
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Deadly simple Git hooks directory setup tool
|
45
|
+
test_files: []
|