renegade 0.1.33 → 0.1.48
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/renegade/branch_name.rb +7 -8
- data/lib/renegade/commit_message.rb +6 -7
- data/lib/renegade/conflict_markers.rb +7 -16
- data/lib/renegade/handle_errors.rb +5 -5
- data/lib/renegade/linters.rb +10 -16
- data/lib/renegade/pre_commit.rb +22 -18
- data/lib/renegade/prepare_commit_msg.rb +11 -14
- data/lib/renegade/protected_files.rb +22 -0
- data/lib/renegade/status.rb +19 -13
- data/lib/renegade/version.rb +1 -1
- metadata +47 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fdcc4d4286010b0ab5c4a48cc331044217cf32c
|
4
|
+
data.tar.gz: 0c21b2038427d11613c95590107bf85afd4db78f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2d245a34f00f9c98a289aaf525ecde69b95f399f219b7ddd1b70d954235e02cde6691908ea42faaf8693aff59f345ebe67db290855fbfe095169f6a38ab4bc3
|
7
|
+
data.tar.gz: 9af1bb1b8f2b941e399448f4677c805b6fe7d9e02240d8290a86fd5943854afd635e9fa0e8b893802b3c5fd3956b19926eae665cd31e327d332321309da461be
|
data/lib/renegade/branch_name.rb
CHANGED
@@ -9,24 +9,23 @@ module Renegade
|
|
9
9
|
REGEX_STORY_BRANCH = /^(?:story)-(\d{4,6})-?(.*)?$/
|
10
10
|
REGEX_BUG_BRANCH = /^(?:bug)-(\d{4,6})-?(.*)?$/
|
11
11
|
|
12
|
-
def initialize
|
12
|
+
def initialize
|
13
13
|
# Instance variables
|
14
|
-
@label =
|
14
|
+
@label = 'Branch Name'
|
15
15
|
@warnings = []
|
16
16
|
@errors = []
|
17
17
|
end
|
18
18
|
|
19
|
-
def run
|
20
|
-
branch_name = `git name-rev --name-only HEAD`
|
19
|
+
def run(branch_name)
|
20
|
+
# branch_name = `git name-rev --name-only HEAD`
|
21
21
|
|
22
22
|
Status.report(@label, check_branch_name(branch_name), true)
|
23
23
|
end
|
24
24
|
|
25
25
|
def check_branch_name(branch_name)
|
26
|
-
if REGEX_STORY_BRANCH.match(branch_name)
|
27
|
-
|
28
|
-
|
29
|
-
elsif REGEX_BUG_BRANCH.match(branch_name)
|
26
|
+
if REGEX_STORY_BRANCH.match(branch_name) ||
|
27
|
+
REGEX_BUG_BRANCH.match(branch_name) ||
|
28
|
+
branch_name == 'master'
|
30
29
|
# placeholder
|
31
30
|
return true
|
32
31
|
else
|
@@ -7,9 +7,8 @@ module Renegade
|
|
7
7
|
|
8
8
|
COMMIT_FORMAT = /^(?:(?:BugId: |Story: B+-|Epic: E-0)[1-9]\d* \| )(.*)/
|
9
9
|
|
10
|
-
def initialize
|
10
|
+
def initialize
|
11
11
|
# Instance variables
|
12
|
-
@label = label
|
13
12
|
@warnings = []
|
14
13
|
@errors = []
|
15
14
|
|
@@ -48,11 +47,11 @@ module Renegade
|
|
48
47
|
end
|
49
48
|
|
50
49
|
def check_commit_message_format_error
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
"You must include a valid BugId, Story or Epic number.\n"\
|
51
|
+
" Examples:\n"\
|
52
|
+
" - BugId: 12345 | Helpful comment describing bug fix\n"\
|
53
|
+
" - Story: B-12345 | Helpful comment describing story\n"\
|
54
|
+
' - Epic: E-12345 | Epic comment'
|
56
55
|
end
|
57
56
|
|
58
57
|
# Check commit message contains no non-ASCII characters
|
@@ -1,31 +1,22 @@
|
|
1
|
-
require 'open3'
|
2
1
|
require 'renegade/status'
|
3
2
|
|
4
3
|
module Renegade
|
5
4
|
##
|
6
5
|
# Prevent merge artifacts from getting committed
|
7
6
|
class ConflictMarkers
|
8
|
-
attr_reader :errors
|
7
|
+
attr_reader :errors
|
9
8
|
|
10
|
-
def initialize
|
11
|
-
|
12
|
-
@label = label
|
9
|
+
def initialize
|
10
|
+
@label = 'No merge artifacts'
|
13
11
|
@errors = []
|
14
12
|
end
|
15
13
|
|
16
|
-
def run
|
17
|
-
markers = `git diff-index --check --cached HEAD --`
|
18
|
-
|
19
|
-
check_markers(markers.chomp.strip)
|
20
|
-
end
|
21
|
-
|
22
|
-
def check_markers(markers)
|
23
|
-
check_label = 'No merge artifacts'
|
24
|
-
|
14
|
+
def run(markers)
|
15
|
+
# markers = `git diff-index --check --cached HEAD --`
|
25
16
|
if markers == ''
|
26
|
-
Status.report(
|
17
|
+
Status.report(@label, true)
|
27
18
|
else
|
28
|
-
Status.report(
|
19
|
+
Status.report(@label, false)
|
29
20
|
@errors.push('Merge artifacts were found!' + "\n" + markers)
|
30
21
|
end
|
31
22
|
end
|
@@ -4,16 +4,16 @@ module Renegade
|
|
4
4
|
class HandleErrors
|
5
5
|
# Handle errors if they exist
|
6
6
|
def self.handle_errors(errors)
|
7
|
-
if errors.
|
8
|
-
|
9
|
-
exit 1
|
7
|
+
if errors.empty?
|
8
|
+
true
|
10
9
|
else
|
11
|
-
|
10
|
+
print_errors(errors)
|
11
|
+
false
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.handle_warnings(warnings)
|
16
|
-
print_warnings(warnings)
|
16
|
+
print_warnings(warnings) unless warnings.empty?
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.print_errors(errors)
|
data/lib/renegade/linters.rb
CHANGED
@@ -19,7 +19,7 @@ module Renegade
|
|
19
19
|
append_file_count(files)
|
20
20
|
|
21
21
|
# Only run check if there are relevant files being committed
|
22
|
-
if files.
|
22
|
+
if files.empty?
|
23
23
|
Status.report(@label, true)
|
24
24
|
else
|
25
25
|
Status.report(@label, exec(files))
|
@@ -30,25 +30,21 @@ module Renegade
|
|
30
30
|
def append_file_count(files)
|
31
31
|
file_size = files.size
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
33
|
+
label_count =
|
34
|
+
(file_size == 0 || file_size > 1) ? "#{file_size} files" : '1 file'
|
35
|
+
|
36
|
+
@label = "#{@label} (#{label_count})"
|
38
37
|
end
|
39
38
|
|
40
39
|
def exec(files)
|
41
40
|
# http://stackoverflow.com/questions/690151/getting-output-of-system-calls-in-ruby
|
42
|
-
|
43
|
-
wait_thread = Open3.popen3(@exec_command
|
41
|
+
stdin, stdout, stderr,
|
42
|
+
wait_thread = Open3.popen3(@exec_command + " #{files.join(' ')}")
|
44
43
|
|
45
|
-
if wait_thread.value.exitstatus == 1
|
46
|
-
@errors.push(stdout.read)
|
47
|
-
end
|
44
|
+
@errors.push(stdout.read) if wait_thread.value.exitstatus == 1
|
48
45
|
|
49
|
-
|
46
|
+
stdin.close
|
50
47
|
stdout.close
|
51
|
-
stderr.gets(nil)
|
52
48
|
stderr.close
|
53
49
|
|
54
50
|
wait_thread.value.exitstatus == 0
|
@@ -58,9 +54,7 @@ module Renegade
|
|
58
54
|
filtered_files = []
|
59
55
|
|
60
56
|
file_list.each do |file|
|
61
|
-
if File.extname(file) == @extension
|
62
|
-
filtered_files.push(file)
|
63
|
-
end
|
57
|
+
filtered_files.push(file) if File.extname(file) == @extension
|
64
58
|
end
|
65
59
|
|
66
60
|
filtered_files
|
data/lib/renegade/pre_commit.rb
CHANGED
@@ -3,34 +3,38 @@ require 'renegade/status'
|
|
3
3
|
require 'renegade/linters'
|
4
4
|
require 'renegade/branch_name'
|
5
5
|
require 'renegade/conflict_markers'
|
6
|
+
require 'renegade/protected_files'
|
6
7
|
|
7
8
|
module Renegade
|
8
9
|
# Run linters
|
9
10
|
class PreCommit
|
10
11
|
def initialize
|
11
12
|
Renegade::Status.hook_start('pre-commit')
|
12
|
-
|
13
|
-
|
14
|
-
@branch_name = Renegade::BranchName.new
|
15
|
-
@conflict_markers = Renegade::ConflictMarkers.new
|
16
|
-
|
17
|
-
|
18
|
-
run
|
13
|
+
@scss_lint = Renegade::Linters.new('SCSS Lint', '.scss', 'scss-lint')
|
14
|
+
@eslint = Renegade::Linters.new('ESLint', '.js', 'eslint')
|
15
|
+
@branch_name = Renegade::BranchName.new
|
16
|
+
@conflict_markers = Renegade::ConflictMarkers.new
|
17
|
+
@protected_files = Renegade::ProtectedFiles.new
|
19
18
|
end
|
20
19
|
|
21
|
-
def run
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
def run(files, branch_name, markers)
|
21
|
+
unless files.empty?
|
22
|
+
files = files.split("\n")
|
23
|
+
@scss_lint.run(files)
|
24
|
+
@eslint.run(files)
|
25
|
+
@branch_name.run(branch_name)
|
26
|
+
@conflict_markers.run(markers)
|
27
|
+
@protected_files.run(files)
|
28
|
+
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
+
handle_errors
|
31
|
+
end
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
def handle_errors
|
34
|
+
Renegade::HandleErrors.handle_warnings(@branch_name.warnings +
|
35
|
+
@protected_files.warnings)
|
36
|
+
Renegade::HandleErrors.handle_errors(@scss_lint.errors +
|
37
|
+
@eslint.errors + @conflict_markers.errors)
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
@@ -3,26 +3,23 @@ require 'renegade/status'
|
|
3
3
|
require 'renegade/commit_message'
|
4
4
|
|
5
5
|
module Renegade
|
6
|
-
# Run
|
6
|
+
# Run prepare commit message hooks
|
7
7
|
class PrepareCommitMsg
|
8
|
-
def initialize
|
9
|
-
|
10
|
-
|
8
|
+
def initialize(args)
|
9
|
+
@message = args[1]
|
10
|
+
@message_file = args[0]
|
11
|
+
|
12
|
+
# Avoid checking merges
|
13
|
+
Renegade::Status.hook_start('prepare-commit-msg') if @message == 'message'
|
11
14
|
end
|
12
15
|
|
13
16
|
def run
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
if @message == 'message' # Avoid checking merges
|
18
|
+
commit_message = Renegade::CommitMessage.new
|
19
|
+
commit_message.run(File.read(@message_file))
|
17
20
|
|
18
|
-
|
19
|
-
if message_type == 'message'
|
20
|
-
message_file = ARGV[0]
|
21
|
-
message = File.read(message_file)
|
22
|
-
commit_message.run(message)
|
21
|
+
Renegade::HandleErrors.handle_errors(commit_message.errors)
|
23
22
|
end
|
24
|
-
|
25
|
-
Renegade::HandleErrors.handle_errors(commit_message.errors)
|
26
23
|
end
|
27
24
|
end
|
28
25
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'renegade/status'
|
2
|
+
|
3
|
+
module Renegade
|
4
|
+
# Check protected files
|
5
|
+
class ProtectedFiles
|
6
|
+
attr_reader :warnings, :protected_files
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
# Instance variables
|
10
|
+
@warnings = []
|
11
|
+
@protected_files = ['app.config', 'web.config']
|
12
|
+
end
|
13
|
+
|
14
|
+
def run(files)
|
15
|
+
files.each do |file|
|
16
|
+
if @protected_files.include?(File.basename(file).downcase)
|
17
|
+
@warnings.push 'Warning! You are making changes to: ' + file.highlight
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/renegade/status.rb
CHANGED
@@ -1,15 +1,23 @@
|
|
1
1
|
# Add color options
|
2
2
|
class String
|
3
|
-
def
|
4
|
-
"\e[
|
3
|
+
def highlight
|
4
|
+
"\e[36m#{self}\e[0m"
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
8
|
-
"\e[
|
7
|
+
def status
|
8
|
+
"\e[35m#{self}\e[0m"
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
"\e[
|
11
|
+
def success
|
12
|
+
"\e[32m √ #{self}\e[0m"
|
13
|
+
end
|
14
|
+
|
15
|
+
def warning
|
16
|
+
"\e[33m × #{self}\e[0m"
|
17
|
+
end
|
18
|
+
|
19
|
+
def error
|
20
|
+
"\e[31m × #{self}\e[0m"
|
13
21
|
end
|
14
22
|
end
|
15
23
|
|
@@ -21,18 +29,16 @@ module Renegade
|
|
21
29
|
# Report labels
|
22
30
|
def self.report(label, passed, warning = nil)
|
23
31
|
if passed
|
24
|
-
puts
|
32
|
+
puts label.success
|
33
|
+
elsif warning
|
34
|
+
puts label.warning
|
25
35
|
else
|
26
|
-
|
27
|
-
puts " × #{label}".yellow
|
28
|
-
else
|
29
|
-
puts " × #{label}".red
|
30
|
-
end
|
36
|
+
puts label.error
|
31
37
|
end
|
32
38
|
end
|
33
39
|
|
34
40
|
def self.hook_start(hook)
|
35
|
-
puts "\
|
41
|
+
puts "\n" + "Running #{hook} hooks…".status
|
36
42
|
end
|
37
43
|
end
|
38
44
|
end
|
data/lib/renegade/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: renegade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.48
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ratherblue
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,20 +38,62 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest-reporters
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.1.7
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.1.7
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rubocop
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
61
|
+
version: 0.37.2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.37.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: scss_lint
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.47.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.47.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: highline
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.7.8
|
48
90
|
type: :development
|
49
91
|
prerelease: false
|
50
92
|
version_requirements: !ruby/object:Gem::Requirement
|
51
93
|
requirements:
|
52
94
|
- - "~>"
|
53
95
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
96
|
+
version: 1.7.8
|
55
97
|
description: Gem description
|
56
98
|
email:
|
57
99
|
- ratherblue@gmail.com
|
@@ -67,6 +109,7 @@ files:
|
|
67
109
|
- lib/renegade/linters.rb
|
68
110
|
- lib/renegade/pre_commit.rb
|
69
111
|
- lib/renegade/prepare_commit_msg.rb
|
112
|
+
- lib/renegade/protected_files.rb
|
70
113
|
- lib/renegade/status.rb
|
71
114
|
- lib/renegade/version.rb
|
72
115
|
homepage: https://github.com/ratherblue/renegade
|