pre-commit 0.37.0 → 0.38.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 +5 -5
- data/lib/plugins/pre_commit/checks/ci.rb +11 -6
- data/lib/plugins/pre_commit/checks/yaml.rb +12 -4
- data/lib/pre-commit.rb +3 -0
- data/lib/pre-commit/checks/grep.rb +7 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 96c57d45df82f130c47a784c55ee806ff6172aa2eac959d38798973f2e902b5e
|
4
|
+
data.tar.gz: b97b72e32177c6ae7d49487e16400e4a6f5c4c05311ec3c61adbaf819e082f76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eb7d67a62bdae21d161bd4d25dbe6222386d9dd688c701846ef0d1aa27c59d8b852d01c0c88d769f7261b98712d3234934549e28f5bee3a3d16ba0a1edf71ef
|
7
|
+
data.tar.gz: da0828e32f361b021278ba1d576a04405346eebd08dccb8527a03b2965ca8ceb71d56c241a4e3da77989391f878ecaf7878d1f3a75b8403c42501827ec962844
|
@@ -2,20 +2,25 @@ require 'pre-commit/checks/plugin'
|
|
2
2
|
|
3
3
|
module PreCommit
|
4
4
|
module Checks
|
5
|
+
##
|
6
|
+
# The CI check will run `rake pre_commmit:ci` before the commit and check
|
7
|
+
# its exit code. If the task runs successfully, the commit will proceed.
|
8
|
+
# If it fails, the commit will be aborted.
|
9
|
+
#
|
5
10
|
class Ci < Plugin
|
6
11
|
CI_TASK_NAME = 'pre_commit:ci'
|
7
12
|
|
13
|
+
def self.description
|
14
|
+
"Runs 'rake #{CI_TASK_NAME} --silent'"
|
15
|
+
end
|
16
|
+
|
8
17
|
def call(_)
|
9
|
-
return if system("rake
|
18
|
+
return if system("rake", CI_TASK_NAME, "--silent")
|
19
|
+
|
10
20
|
PreCommit::ErrorList.new(
|
11
21
|
"your test suite has failed, for the full output run `#{CI_TASK_NAME}`"
|
12
22
|
)
|
13
23
|
end
|
14
|
-
|
15
|
-
def self.description
|
16
|
-
"Runs 'rake #{CI_TASK_NAME} --silent'"
|
17
|
-
end
|
18
|
-
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
@@ -1,9 +1,19 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
require 'yaml'
|
2
4
|
require 'pre-commit/checks/plugin'
|
3
5
|
|
4
6
|
module PreCommit
|
5
7
|
module Checks
|
8
|
+
##
|
9
|
+
# The Yaml check will read and parse YAML files to ensure they have valid
|
10
|
+
# syntax.
|
11
|
+
#
|
6
12
|
class Yaml < Plugin
|
13
|
+
def self.description
|
14
|
+
'Runs yaml to detect errors.'
|
15
|
+
end
|
16
|
+
|
7
17
|
def call(staged_files)
|
8
18
|
staged_files = staged_files.grep(/\.(yml|yaml)$/)
|
9
19
|
return if staged_files.empty?
|
@@ -13,6 +23,8 @@ module PreCommit
|
|
13
23
|
errors.join("\n") + "\n" unless errors.empty?
|
14
24
|
end
|
15
25
|
|
26
|
+
private
|
27
|
+
|
16
28
|
def load_file(file)
|
17
29
|
if YAML.respond_to?(:safe_load)
|
18
30
|
safe_load_file(file)
|
@@ -39,10 +51,6 @@ module PreCommit
|
|
39
51
|
rescue ArgumentError
|
40
52
|
$stdout.puts "Warning: Skipping '#{file}' because it contains serialized ruby objects."
|
41
53
|
end
|
42
|
-
|
43
|
-
def self.description
|
44
|
-
'Runs yaml to detect errors.'
|
45
|
-
end
|
46
54
|
end
|
47
55
|
end
|
48
56
|
end
|
data/lib/pre-commit.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
1
3
|
require 'pre-commit/checks/shell'
|
2
4
|
require 'pre-commit/error_list'
|
3
5
|
require 'pre-commit/line'
|
@@ -91,7 +93,11 @@ module PreCommit
|
|
91
93
|
end
|
92
94
|
|
93
95
|
def detect_grep_version
|
94
|
-
|
96
|
+
first_line = Open3.popen2('grep', '--version') do |_, stdout, _|
|
97
|
+
stdout.readline
|
98
|
+
end
|
99
|
+
|
100
|
+
first_line.sub(/^[^0-9.]*\([0-9.]*\)$/, '\1')
|
95
101
|
end
|
96
102
|
|
97
103
|
def extra_execute(files)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pre-commit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.38.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shajith Chacko, Josh Lubaway
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pluginator
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
89
|
+
version: '0.49'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
96
|
+
version: '0.49'
|
97
97
|
description: A git pre-commit hook written in ruby with a few more tricks up its sleeve
|
98
98
|
email: dontneedmoreemail@example.com
|
99
99
|
executables:
|
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
198
|
version: '0'
|
199
199
|
requirements: []
|
200
200
|
rubyforge_project:
|
201
|
-
rubygems_version: 2.
|
201
|
+
rubygems_version: 2.7.3
|
202
202
|
signing_key:
|
203
203
|
specification_version: 3
|
204
204
|
summary: A slightly better git pre-commit hook
|