xlint 0.0.4 → 0.0.5
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/README.md +1 -1
- data/lib/xlint.rb +22 -6
- data/lib/xlint/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44ff74fe99426f97c888147083f625d0a5cc9d60
|
4
|
+
data.tar.gz: 4a5537b2eafb5d7d5e071b1e1e0654be3807810f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2fb76abcce5b30a6aec4c498049c775fb0462299e18fd08452e6b5be3f1cb1d6449773c099298eff13a5cad12c1d16d35674768636452c66c6820b33a0bbad1
|
7
|
+
data.tar.gz: 5918d137e4bf58c957b68d2aab5eba3a46bddea6f551d4416fbfeef6890ab6811d60e3ab9431e93c8490024353a38a841f791ec0520f5ac2d6706e4db1a97ab8
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[](https://rubygems.org/gems/xlint)
|
4
4
|
[](https://travis-ci.org/instructure/xlint)
|
5
5
|
[](https://codeclimate.com/github/instructure/xlint)
|
6
|
-
[](https://coveralls.io/github/instructure/xlint?branch=HEAD)
|
7
7
|
[](https://gemnasium.com/github.com/instructure/xlint)
|
8
8
|
|
9
9
|
Xlint is command-line tool for linting XCode project files and posting
|
data/lib/xlint.rb
CHANGED
@@ -7,10 +7,11 @@ require 'gergich'
|
|
7
7
|
|
8
8
|
class Xlint
|
9
9
|
class << self
|
10
|
-
attr_accessor :diff_file, :comments
|
10
|
+
attr_accessor :diff_file, :draft, :comments
|
11
11
|
|
12
12
|
def clear
|
13
13
|
@diff_file = nil
|
14
|
+
@draft.reset! if draft
|
14
15
|
@comments = []
|
15
16
|
end
|
16
17
|
|
@@ -28,7 +29,11 @@ class Xlint
|
|
28
29
|
|
29
30
|
def build_draft
|
30
31
|
@comments = []
|
31
|
-
|
32
|
+
# GitDiffParser::Patches.parse(cp932 text) raises ArgumentError: invalid byte sequence in UTF-8
|
33
|
+
# https://github.com/packsaddle/ruby-git_diff_parser/issues/91
|
34
|
+
diff_data = File.read(diff_file)
|
35
|
+
diff_data.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
|
36
|
+
diff = Xlint.parse_git(diff_data)
|
32
37
|
diff.files.each do |file|
|
33
38
|
patch = diff.find_patch_by_file(file)
|
34
39
|
changes = Xlint.patch_body_changes(patch.body, file)
|
@@ -37,15 +42,21 @@ class Xlint
|
|
37
42
|
end
|
38
43
|
|
39
44
|
def save_draft
|
40
|
-
|
41
|
-
draft = Gergich::Draft.new
|
45
|
+
@draft = Gergich::Draft.new
|
42
46
|
comments.each do |comment|
|
43
47
|
draft.add_comment(comment[:path], comment[:position], comment[:message], comment[:severity])
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
51
|
+
def build_label
|
52
|
+
return unless ENV['GERGICH_REVIEW_LABEL']
|
53
|
+
score = comments.empty? ? 1 : -1
|
54
|
+
message = comments.empty? ? 'Xlint didn\'t find anything to complain about' : 'Xlint is worried about your commit'
|
55
|
+
draft.add_message(message)
|
56
|
+
draft.add_label(ENV['GERGICH_REVIEW_LABEL'], score)
|
57
|
+
end
|
58
|
+
|
47
59
|
def publish_draft
|
48
|
-
return if comments.empty?
|
49
60
|
Gergich::Review.new.publish!
|
50
61
|
end
|
51
62
|
|
@@ -54,6 +65,7 @@ class Xlint
|
|
54
65
|
check_env
|
55
66
|
build_draft
|
56
67
|
save_draft
|
68
|
+
build_label
|
57
69
|
publish_draft
|
58
70
|
end
|
59
71
|
|
@@ -65,7 +77,7 @@ class Xlint
|
|
65
77
|
result = []
|
66
78
|
line_number = 0
|
67
79
|
body.split("\n").each do |line|
|
68
|
-
if
|
80
|
+
if valid_git_header?(line)
|
69
81
|
line_number = starting_line_number(line)
|
70
82
|
next
|
71
83
|
end
|
@@ -107,5 +119,9 @@ class Xlint
|
|
107
119
|
end
|
108
120
|
offenses
|
109
121
|
end
|
122
|
+
|
123
|
+
def valid_git_header?(line)
|
124
|
+
line =~ /^(@{2})\s([-]{1}[0-9]*(,[0-9]*)?)\s([+][0-9]*(,[0-9]*)?)\s(@{2})$/
|
125
|
+
end
|
110
126
|
end
|
111
127
|
end
|
data/lib/xlint/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xlint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|