set_git_hooks_dir 0.0.6 → 0.0.7
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 +4 -4
- data/LICENSE +20 -0
- data/README.md +38 -0
- data/lib/rubygems_plugin.rb +0 -1
- data/lib/set_git_hooks_dir.rb +2 -14
- data/plugins.rb +7 -5
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 976195685caba3b76712236bc1bd6b7d47531ed7313dddfab5f2f3a29d8d8064
|
4
|
+
data.tar.gz: 8d107ed8fa79b2b0933a6e8916b165518072058ba967c2938de1fbfadfff5e17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87fba99429a671ec0c18ef760864d8668dafe91be0b8597406d27e045d1f4fb362eb55aab0f7b065501cf3f9cd38d8540c425b64b5e80db5fb6be6b506e92183
|
7
|
+
data.tar.gz: d617440c4336aaece2109608205a23a32abec4a9543142ed5cf517bccceeb31f06575f5e029b9b4c9a6dbd1049c2751e7f537e8a4342158d60b6d666f11b14bd
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 rhysd
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
16
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
17
|
+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
20
|
+
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
`set_git_hooks_dir` Ruby package
|
2
|
+
================================
|
3
|
+
[![gem][gem-badge]][gem]
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
See https://github.com/rhysd/set-git-hooks-dir#readme for the usage.
|
8
|
+
|
9
|
+
## Details
|
10
|
+
|
11
|
+
This gem aims to be used as both bundler and rubygems plugins so that this gem can hook the package installation and
|
12
|
+
configure Git hooks properly.
|
13
|
+
|
14
|
+
So why can't this gem be a simple rubygems plugin? The answer is that bundler doesn't run rubygems plugin's install
|
15
|
+
hooks on `bundle install`. bundler downloads gems from rubygems.org and stores the downloaded gems to the
|
16
|
+
[`BUNDLE_PATH`][path] directory and makes them loadable. However, this doesn't mean *installing* the gems. It just
|
17
|
+
*stores*. It is very confusing that `gem install` *installs* a gem but `bundle install` does not *install* a gem. The
|
18
|
+
following issue mentions this behavior:
|
19
|
+
|
20
|
+
https://github.com/rubygems/bundler/issues/5429
|
21
|
+
|
22
|
+
> Running `bundle install` with `path` gems does not install those gems. The `path` feature is a shortcut to add the
|
23
|
+
> path to `$LOAD_PATH`, and does not do any of the usual gem installation procedures.
|
24
|
+
|
25
|
+
The detailed behavior of this gem in each cases are as follows:
|
26
|
+
|
27
|
+
- On `bundle install`, this gem works as a bundler plugin. bundler loads the plugin on installation and it configures
|
28
|
+
Git hooks.
|
29
|
+
- On `gem install`, this gem works as a rubygems plugin. rubygems runs a install hook of the plugin and the hook
|
30
|
+
configures Git hooks.
|
31
|
+
|
32
|
+
## License
|
33
|
+
|
34
|
+
This npm package is distributed under [the MIT license](LICENSE).
|
35
|
+
|
36
|
+
[gem-badge]: https://img.shields.io/gem/v/set_git_hooks_dir
|
37
|
+
[gem]: https://rubygems.org/gems/set_git_hooks_dir
|
38
|
+
[path]: https://bundler.io/v1.12/man/bundle-config.1.html#LIST-OF-AVAILABLE-KEYS
|
data/lib/rubygems_plugin.rb
CHANGED
data/lib/set_git_hooks_dir.rb
CHANGED
@@ -7,12 +7,7 @@ class SetGitHooksDir
|
|
7
7
|
SKIP_ENV_VARS = %w[SET_GIT_HOOKS_DIR_SKIP GITHUB_ACTION CI JENKINS_URL].freeze
|
8
8
|
|
9
9
|
def setup(hooks_dir)
|
10
|
-
if SKIP_ENV_VARS.lazy.filter_map { |n| ENV[n] }.any? { |v| !v.empty? }
|
11
|
-
puts 'CI environment is detected. Skip setting Git hooks'
|
12
|
-
return
|
13
|
-
end
|
14
|
-
|
15
|
-
puts "Start setting hooks directory: #{hooks_dir}"
|
10
|
+
return if SKIP_ENV_VARS.lazy.filter_map { |n| ENV[n] }.any? { |v| !v.empty? }
|
16
11
|
|
17
12
|
hooks_dir = Pathname.new hooks_dir
|
18
13
|
cwd = Pathname.pwd
|
@@ -20,20 +15,13 @@ class SetGitHooksDir
|
|
20
15
|
.filter_map { |dir| dir + '.git' if (dir + hooks_dir).directory? }
|
21
16
|
.find { |dotgit| dotgit.exist? }
|
22
17
|
|
23
|
-
puts "Repository config directory: #{dotgit}"
|
24
|
-
|
25
18
|
raise StandardError.new("Git hooks directory #{hooks_dir} was not found at any root of GitHub repository in #{cwd}") unless dotgit
|
26
|
-
if dotgit.directory? && File.read(dotgit + 'config').include?("\n\thooksPath = ")
|
27
|
-
puts 'core.hooksPath is already set. Skip setting Git hooks'
|
28
|
-
return
|
29
|
-
end
|
19
|
+
return if dotgit.directory? && File.read(dotgit + 'config').include?("\n\thooksPath = ")
|
30
20
|
|
31
21
|
git = ENV['SET_GIT_HOOKS_DIR_GIT']
|
32
22
|
git = 'git' if git.nil? || git.empty?
|
33
|
-
puts "Running `#{git} config core.hooksPath #{hooks_dir}`"
|
34
23
|
out = `#{git} config core.hooksPath #{hooks_dir}`
|
35
24
|
raise StandardError.new("`#{git} config core.hooksPath #{hooks_dir}` failed with status #{$?.exitstatus}: #{out}") unless $?.success?
|
36
|
-
puts 'Done!'
|
37
25
|
end
|
38
26
|
end
|
39
27
|
end
|
data/plugins.rb
CHANGED
@@ -9,9 +9,11 @@ require 'set_git_hooks_dir'
|
|
9
9
|
#
|
10
10
|
# https://github.com/rubygems/bundler/issues/5429
|
11
11
|
#
|
12
|
-
# To enable automatic hooks configuration
|
13
|
-
# `
|
14
|
-
# plugin.
|
12
|
+
# To enable automatic hooks configuration via `bundle install`, this package needs to be installed as a bundler plugin.
|
13
|
+
# For the case of `gem install`, `lib/rubygems_plugin.rb` remains (though I don't know the use case).
|
15
14
|
|
16
|
-
|
17
|
-
SetGitHooksDir.setup '.git-hooks'
|
15
|
+
begin
|
16
|
+
SetGitHooksDir.setup '.git-hooks'
|
17
|
+
rescue StandardError => exc
|
18
|
+
raise Bundler::BundlerError.new exc.message
|
19
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: set_git_hooks_dir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rhysd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: set_git_hooks_dir is a deadly simple gem to configure your Git hooks
|
14
14
|
on package installation
|
15
|
-
email:
|
15
|
+
email:
|
16
|
+
- lin90162@yahoo.co.jp
|
16
17
|
executables: []
|
17
18
|
extensions: []
|
18
|
-
extra_rdoc_files:
|
19
|
+
extra_rdoc_files:
|
20
|
+
- README.md
|
19
21
|
files:
|
22
|
+
- LICENSE
|
23
|
+
- README.md
|
20
24
|
- lib/rubygems_plugin.rb
|
21
25
|
- lib/set_git_hooks_dir.rb
|
22
26
|
- plugins.rb
|
23
27
|
homepage: https://rubygems.org/gems/set_git_hooks_dir
|
24
28
|
licenses:
|
25
29
|
- MIT
|
26
|
-
metadata:
|
30
|
+
metadata:
|
31
|
+
homepage_uri: https://rubygems.org/gems/set_git_hooks_dir
|
32
|
+
source_code_uri: https://github.com/rhysd/set-git-hooks-dir
|
27
33
|
post_install_message:
|
28
34
|
rdoc_options: []
|
29
35
|
require_paths:
|