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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bcfee8fd2980a89cb729e4d32a8e6983c38a2d56
4
- data.tar.gz: 74967a5b0109001208b35cbeffe82165af6cda96
3
+ metadata.gz: 44ff74fe99426f97c888147083f625d0a5cc9d60
4
+ data.tar.gz: 4a5537b2eafb5d7d5e071b1e1e0654be3807810f
5
5
  SHA512:
6
- metadata.gz: 69fbb304de54c93cecc8fcec72bc72b5c331e46077879711898e75d9bf959c5af137c9da3931ee36d65d4ec38162956f1840dbbc33c1a642ddd6aa9e673cb500
7
- data.tar.gz: 6fe7769a80dead24dc1fdc4978ad6bf0c1c0800c3bc49dc6bfabb3dd147c883c6e0ccbdc5deeae26a217e7700dfc33fe57e83907fbe0bd4a1749ba6fa93413af
6
+ metadata.gz: e2fb76abcce5b30a6aec4c498049c775fb0462299e18fd08452e6b5be3f1cb1d6449773c099298eff13a5cad12c1d16d35674768636452c66c6820b33a0bbad1
7
+ data.tar.gz: 5918d137e4bf58c957b68d2aab5eba3a46bddea6f551d4416fbfeef6890ab6811d60e3ab9431e93c8490024353a38a841f791ec0520f5ac2d6706e4db1a97ab8
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/xlint.svg)](https://rubygems.org/gems/xlint)
4
4
  [![Build Status](https://travis-ci.org/instructure/xlint.svg?branch=master)](https://travis-ci.org/instructure/xlint)
5
5
  [![Code Climate](https://codeclimate.com/github/instructure/xlint/badges/gpa.svg)](https://codeclimate.com/github/instructure/xlint)
6
- [![Coverage Status](https://coveralls.io/repos/github/instructure/xlint/badge.svg?branch=master)](https://coveralls.io/github/instructure/xlint?branch=master)
6
+ [![Coverage Status](https://coveralls.io/repos/github/instructure/xlint/badge.svg?branch=HEAD)](https://coveralls.io/github/instructure/xlint?branch=HEAD)
7
7
  [![Dependency Status](https://gemnasium.com/badges/github.com/instructure/xlint.svg)](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
- diff = Xlint.parse_git(File.read(diff_file))
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
- return if comments.empty?
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 line.start_with?('@@')
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
@@ -1,3 +1,3 @@
1
1
  class Xlint
2
- VERSION = '0.0.4'.freeze unless defined? ::Xlint::VERSION
2
+ VERSION = '0.0.5'.freeze unless defined? ::Xlint::VERSION
3
3
  end
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
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-13 00:00:00.000000000 Z
11
+ date: 2016-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git