rbgithook 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/Gemfile.lock +1 -1
- data/exe/rbgithook +14 -5
- data/lib/rbgithook/version.rb +1 -1
- data/lib/rbgithook.rb +40 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c71ca6cde42b02269ac1aeee9e663bb5b516b2fdecc66d79431b44d1562ad996
|
4
|
+
data.tar.gz: 9b7eb15086882d290128c30e49a127d419957a2eb23868de0611e31cf8d52879
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28ec92618c41e81d9f6170fc708ef2299b2bcfc923efe20cdf0975dcc52ea5cac28da7f95601cec30146a81fe7f1356c17d4ecda2508bd7332a67e1e6040771f
|
7
|
+
data.tar.gz: 4a027d02efb93afcd777733bb8feb2ce67a2e40a63ce22009d7bf567525fb382cff94c3f82a026324146790131cf04f0835daaa6a5e5a62f157debe0eb9c1fcb
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/exe/rbgithook
CHANGED
@@ -4,10 +4,19 @@ require "rbgithook"
|
|
4
4
|
require "fileutils"
|
5
5
|
|
6
6
|
command = ARGV[0]
|
7
|
-
args = ARGV[1..]
|
8
7
|
|
9
|
-
if
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
if command.nil?
|
9
|
+
warn "Please specify a command to run\n\n"
|
10
|
+
Rbgithook.help
|
11
|
+
exit 1
|
13
12
|
end
|
13
|
+
|
14
|
+
cmds = {
|
15
|
+
"install" => ->(_) { Rbgithook.install },
|
16
|
+
"set" => ->(args) { Rbgithook.set(args) },
|
17
|
+
"add" => ->(args) { Rbgithook.add(args) },
|
18
|
+
"uninstall" => ->(_) { Rbgithook.uninstall },
|
19
|
+
"help" => ->(_) { Rbgithook.help }
|
20
|
+
}
|
21
|
+
|
22
|
+
cmds.key?(command) ? cmds[command].call(ARGV[1..]) : Rbgithook.help
|
data/lib/rbgithook/version.rb
CHANGED
data/lib/rbgithook.rb
CHANGED
@@ -12,28 +12,63 @@ module Rbgithook
|
|
12
12
|
|
13
13
|
def self.set(args)
|
14
14
|
file_name = args[0]
|
15
|
+
if file_name.nil?
|
16
|
+
warn "Please specify a file to hook"
|
17
|
+
exit 1
|
18
|
+
end
|
15
19
|
hook_command = args[1]
|
20
|
+
if hook_command.nil?
|
21
|
+
warn "Please specify a command to run"
|
22
|
+
exit 1
|
23
|
+
end
|
16
24
|
Dir.chdir(".rbgithook")
|
17
25
|
file = File.open(file_name.to_s, "w")
|
18
|
-
file.write("#!/usr/bin/env sh\n")
|
19
|
-
file.write(hook_command)
|
26
|
+
file.write("#!/usr/bin/env sh\n#{hook_command}")
|
20
27
|
FileUtils.chmod(0o755, file_name)
|
21
28
|
end
|
22
29
|
|
23
30
|
def self.add(args)
|
24
31
|
file_name = args[0]
|
32
|
+
if file_name.nil?
|
33
|
+
warn "Please specify a file to hook"
|
34
|
+
exit 1
|
35
|
+
end
|
25
36
|
hook_command = args[1]
|
26
|
-
|
37
|
+
if hook_command.nil?
|
38
|
+
warn "Please specify a command to run"
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
dir_name = ".rbgithook"
|
42
|
+
unless Dir.exist?(dir_name)
|
43
|
+
warning_message("Directory", file_name, hook_command)
|
44
|
+
exit 1
|
45
|
+
end
|
46
|
+
Dir.chdir(dir_name)
|
27
47
|
if File.exist?(file_name)
|
28
48
|
file = File.open(file_name.to_s, "a")
|
29
49
|
file.write("\n#{hook_command}")
|
30
|
-
FileUtils.chmod(0o755, file_name)
|
31
50
|
else
|
32
|
-
|
51
|
+
warning_message("File", file_name, hook_command)
|
33
52
|
end
|
34
53
|
end
|
35
54
|
|
36
55
|
def self.uninstall
|
37
56
|
system("git", "config", "--unset", "core.hooksPath")
|
38
57
|
end
|
58
|
+
|
59
|
+
def self.help
|
60
|
+
puts <<~USAGE
|
61
|
+
bgithook [command] {file} {command}
|
62
|
+
|
63
|
+
install - Install hook
|
64
|
+
set {file} {command} - Set a hook
|
65
|
+
add {file} {command} - Add a hook
|
66
|
+
uninstall - Uninstall hook
|
67
|
+
help - Show this usage
|
68
|
+
USAGE
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.warning_message(target, file_name, hook_command)
|
72
|
+
warn "#{target} not found, please run `rbgithook set #{file_name} '#{hook_command}'`"
|
73
|
+
end
|
39
74
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbgithook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hyuraku
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Simple Git hook made by Ruby
|
14
14
|
email:
|