rbgithook 0.1.2 → 0.1.3
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/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/Steepfile +6 -0
- data/exe/rbgithook +0 -1
- data/lib/rbgithook/version.rb +1 -1
- data/lib/rbgithook.rb +34 -31
- data/sig/rbgithook.rbs +16 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 126208371ad980b74efb9d3f90452e9ae9b05616d177a792e07c774e206f1f26
|
4
|
+
data.tar.gz: 98e3cff68de8a6946e00084e9d96fdeb1c7a329e6e8158c8b940ad3c6b6b8389
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 101812bf06163703ea445fb781ccaf8457cb832ec36c37c98a7c978278232d28b12c9f4a5050d472f5d373bb10e3499865afbba7a28303dc87d93feec88752bf
|
7
|
+
data.tar.gz: cd6b654b1fba6548bc5453a885c60f8a24496cf09d35f308a6da5da0fa90c1cfff0d5233ddca7792a20e264e65b68835fff7b4a18708cbce8cd2f3b47823f952
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/Steepfile
ADDED
data/exe/rbgithook
CHANGED
data/lib/rbgithook/version.rb
CHANGED
data/lib/rbgithook.rb
CHANGED
@@ -1,52 +1,39 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "rbgithook/version"
|
4
|
+
require "fileutils"
|
4
5
|
|
5
6
|
module Rbgithook
|
7
|
+
DIRNAME = ".rbgithook"
|
8
|
+
|
6
9
|
def self.install
|
7
|
-
|
8
|
-
FileUtils.mkdir(dir) unless Dir.exist?(dir)
|
10
|
+
FileUtils.mkdir(DIRNAME) unless Dir.exist?(DIRNAME)
|
9
11
|
|
10
|
-
system("git", "config", "core.hooksPath",
|
12
|
+
system("git", "config", "core.hooksPath", DIRNAME)
|
11
13
|
end
|
12
14
|
|
13
15
|
def self.set(args)
|
14
|
-
file_name = args[0]
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
hook_command = args[1]
|
20
|
-
if hook_command.nil?
|
21
|
-
warn "Please specify a command to run"
|
22
|
-
exit 1
|
16
|
+
file_name = get_file_name(args[0])
|
17
|
+
hook_command = get_hook_command(args[1])
|
18
|
+
Dir.chdir(DIRNAME)
|
19
|
+
File.open(file_name.to_s, "w") do |file|
|
20
|
+
file.write("#!/usr/bin/env sh\n#{hook_command}")
|
23
21
|
end
|
24
|
-
Dir.chdir(".rbgithook")
|
25
|
-
file = File.open(file_name.to_s, "w")
|
26
|
-
file.write("#!/usr/bin/env sh\n#{hook_command}")
|
27
22
|
FileUtils.chmod(0o755, file_name)
|
28
23
|
end
|
29
24
|
|
30
25
|
def self.add(args)
|
31
|
-
file_name = args[0]
|
32
|
-
|
33
|
-
|
34
|
-
exit 1
|
35
|
-
end
|
36
|
-
hook_command = args[1]
|
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)
|
26
|
+
file_name = get_file_name(args[0])
|
27
|
+
hook_command = get_hook_command(args[1])
|
28
|
+
unless Dir.exist?(DIRNAME)
|
43
29
|
warning_message("Directory", file_name, hook_command)
|
44
30
|
exit 1
|
45
31
|
end
|
46
|
-
Dir.chdir(
|
32
|
+
Dir.chdir(DIRNAME)
|
47
33
|
if File.exist?(file_name)
|
48
|
-
|
49
|
-
|
34
|
+
File.open(file_name.to_s, "a") do |file|
|
35
|
+
file.write("\n#{hook_command}")
|
36
|
+
end
|
50
37
|
else
|
51
38
|
warning_message("File", file_name, hook_command)
|
52
39
|
end
|
@@ -58,7 +45,7 @@ module Rbgithook
|
|
58
45
|
|
59
46
|
def self.help
|
60
47
|
puts <<~USAGE
|
61
|
-
|
48
|
+
rbgithook [command] {file} {command}
|
62
49
|
|
63
50
|
install - Install hook
|
64
51
|
set {file} {command} - Set a hook
|
@@ -71,4 +58,20 @@ module Rbgithook
|
|
71
58
|
def self.warning_message(target, file_name, hook_command)
|
72
59
|
warn "#{target} not found, please run `rbgithook set #{file_name} '#{hook_command}'`"
|
73
60
|
end
|
61
|
+
|
62
|
+
def self.get_file_name(file_name)
|
63
|
+
if file_name.nil?
|
64
|
+
warn "Please specify a file to hook"
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
file_name
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.get_hook_command(hook_command)
|
71
|
+
if hook_command.nil?
|
72
|
+
warn "Please specify a command to run"
|
73
|
+
exit 1
|
74
|
+
end
|
75
|
+
hook_command
|
76
|
+
end
|
74
77
|
end
|
data/sig/rbgithook.rbs
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# TypeProf 0.21.3
|
2
|
+
|
3
|
+
# Classes
|
4
|
+
module Rbgithook
|
5
|
+
VERSION: String
|
6
|
+
DIRNAME: String
|
7
|
+
|
8
|
+
def self.install: -> void
|
9
|
+
def self.set: (Array[String] args) -> void
|
10
|
+
def self.add: (Array[String] args) -> void
|
11
|
+
def self.uninstall: -> void
|
12
|
+
def self.help: -> void
|
13
|
+
def self.warning_message: (String target, String file_name, String hook_command) -> void
|
14
|
+
def self.get_file_name: (String file_name) -> String
|
15
|
+
def self.get_hook_command: (String hook_command) -> String
|
16
|
+
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hyuraku
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06
|
11
|
+
date: 2022-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Simple Git hook made by Ruby
|
14
14
|
email:
|
@@ -27,10 +27,12 @@ files:
|
|
27
27
|
- LICENSE.txt
|
28
28
|
- README.md
|
29
29
|
- Rakefile
|
30
|
+
- Steepfile
|
30
31
|
- exe/rbgithook
|
31
32
|
- lib/rbgithook.rb
|
32
33
|
- lib/rbgithook/version.rb
|
33
34
|
- rbgithook.gemspec
|
35
|
+
- sig/rbgithook.rbs
|
34
36
|
homepage: https://github.com/hyuraku/rbgithook
|
35
37
|
licenses:
|
36
38
|
- MIT
|