git_diff_parser 2.3.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.conventional-changelog.context.js +0 -0
- data/.github/workflows/ci.yaml +28 -0
- data/.gitignore +1 -0
- data/.rspec +0 -0
- data/.rubocop.yml +0 -0
- data/.tachikoma.yml +0 -0
- data/CODE_OF_CONDUCT.md +0 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/changelog.md +31 -0
- data/git_diff_parser.gemspec +0 -0
- data/lib/git_diff_parser/diff_parser.rb +0 -0
- data/lib/git_diff_parser/line.rb +0 -0
- data/lib/git_diff_parser/patch.rb +26 -0
- data/lib/git_diff_parser/patches.rb +11 -2
- data/lib/git_diff_parser/version.rb +1 -1
- data/lib/git_diff_parser.rb +0 -0
- data/package.json +2 -2
- data/thoughtbot-hound/LICENSE +0 -0
- metadata +4 -6
- data/.travis.yml +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 986edf351b61fb5ffee66918df85a9b36f769a58dc1acac0fa8932cd3039e745
|
4
|
+
data.tar.gz: f287924bf315d0542fa6e2cb3b6cb115fde3320c9fc84bab7299ad135daadaa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7dd831db0671683540cb4c073499229fef3e4c9033f236121d7ddfcebd8f4c91439d1a5cb84b2fe491cbf3b642fbc85f1cbb7e0e4f0ac35220df4058b7c9105
|
7
|
+
data.tar.gz: 222af9d5750d2e15bbbbf273a0c64ebac75702dd37495cd52981c36f02f651f9f21b197321064cfdf1098b6141fdd0b0dec0bdeb7c1d30b056efe84b3753c442
|
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
types:
|
9
|
+
- opened
|
10
|
+
- synchronize
|
11
|
+
- reopened
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
test:
|
15
|
+
strategy:
|
16
|
+
fail-fast: false
|
17
|
+
matrix:
|
18
|
+
os: [ubuntu-latest]
|
19
|
+
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
20
|
+
ruby: [2.6, 2.7, '3.0', head]
|
21
|
+
runs-on: ${{ matrix.os }}
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v2
|
24
|
+
- uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: ${{ matrix.ruby }}
|
27
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
28
|
+
- run: bundle exec rake
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
File without changes
|
data/.rubocop.yml
CHANGED
File without changes
|
data/.tachikoma.yml
CHANGED
File without changes
|
data/CODE_OF_CONDUCT.md
CHANGED
File without changes
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/changelog.md
CHANGED
@@ -1,3 +1,34 @@
|
|
1
|
+
# [4.0.0](https://github.com/packsaddle/ruby-git_diff_parser/compare/v3.2.0...v4.0.0) (2021-11-04)
|
2
|
+
|
3
|
+
### BREAKING CHANGES
|
4
|
+
|
5
|
+
* **patch:** Fix changed_lines number calculation ([30bfcf5](https://github.com/packsaddle/ruby-git_diff_parser/commit/30bfcf5)) [#336](https://github.com/packsaddle/ruby-git_diff_parser/pull/336)
|
6
|
+
|
7
|
+
|
8
|
+
<a name="3.2.0"></a>
|
9
|
+
# [3.2.0](https://github.com/packsaddle/ruby-git_diff_parser/compare/v3.1.0...v3.2.0) (2019-03-13)
|
10
|
+
|
11
|
+
### Fixes
|
12
|
+
|
13
|
+
* **patches:** Fix trailing whitespace issue in filename parsing ([d679ad1](https://github.com/packsaddle/ruby-git_diff_parser/commit/d679ad1))
|
14
|
+
|
15
|
+
|
16
|
+
<a name="3.1.0"></a>
|
17
|
+
# [3.1.0](https://github.com/packsaddle/ruby-git_diff_parser/compare/v3.0.0...v3.1.0) (2017-07-05)
|
18
|
+
|
19
|
+
### Features
|
20
|
+
|
21
|
+
* **patch:** Added Patch#removed_lines method ([9acc263](https://github.com/packsaddle/ruby-git_diff_parser/commit/9acc263))
|
22
|
+
|
23
|
+
|
24
|
+
<a name="3.0.0"></a>
|
25
|
+
# [3.0.0](https://github.com/packsaddle/ruby-git_diff_parser/compare/v2.3.0...v3.0.0) (2017-06-22)
|
26
|
+
|
27
|
+
### Features
|
28
|
+
|
29
|
+
* **patches:** convert non UTF-8 string to avoid invalid UTF-8 sequence errors ([a8f87bd](https://github.com/packsaddle/ruby-git_diff_parser/commit/a8f87bd))
|
30
|
+
|
31
|
+
|
1
32
|
<a name="2.3.0"></a>
|
2
33
|
# [2.3.0](https://github.com/packsaddle/ruby-git_diff_parser/compare/v2.2.0...v2.3.0) (2016-05-12)
|
3
34
|
|
data/git_diff_parser.gemspec
CHANGED
File without changes
|
File without changes
|
data/lib/git_diff_parser/line.rb
CHANGED
File without changes
|
@@ -3,7 +3,9 @@ module GitDiffParser
|
|
3
3
|
class Patch
|
4
4
|
RANGE_INFORMATION_LINE = /^@@ .+\+(?<line_number>\d+),/
|
5
5
|
MODIFIED_LINE = /^\+(?!\+|\+)/
|
6
|
+
REMOVED_LINE = /^[-]/
|
6
7
|
NOT_REMOVED_LINE = /^[^-]/
|
8
|
+
NO_NEWLINE_MESSAGE = /^\$/
|
7
9
|
|
8
10
|
attr_accessor :file, :body, :secure_hash
|
9
11
|
# @!attribute [rw] file
|
@@ -60,6 +62,8 @@ module GitDiffParser
|
|
60
62
|
case content
|
61
63
|
when RANGE_INFORMATION_LINE
|
62
64
|
line_number = Regexp.last_match[:line_number].to_i
|
65
|
+
when NO_NEWLINE_MESSAGE
|
66
|
+
# nop
|
63
67
|
when MODIFIED_LINE
|
64
68
|
line = Line.new(
|
65
69
|
content: content,
|
@@ -76,6 +80,28 @@ module GitDiffParser
|
|
76
80
|
end
|
77
81
|
end
|
78
82
|
|
83
|
+
# @return [Array<Line>] removed lines
|
84
|
+
def removed_lines
|
85
|
+
line_number = 0
|
86
|
+
|
87
|
+
lines.each_with_index.inject([]) do |lines, (content, patch_position)|
|
88
|
+
case content
|
89
|
+
when RANGE_INFORMATION_LINE
|
90
|
+
line_number = Regexp.last_match[:line_number].to_i
|
91
|
+
when REMOVED_LINE
|
92
|
+
line = Line.new(
|
93
|
+
content: content,
|
94
|
+
number: line_number,
|
95
|
+
patch_position: patch_position
|
96
|
+
)
|
97
|
+
lines << line
|
98
|
+
line_number += 1
|
99
|
+
end
|
100
|
+
|
101
|
+
lines
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
79
105
|
# @return [Array<Integer>] changed line numbers
|
80
106
|
def changed_line_numbers
|
81
107
|
changed_lines.map(&:number)
|
@@ -18,7 +18,7 @@ module GitDiffParser
|
|
18
18
|
line_count = lines.count
|
19
19
|
parsed = new
|
20
20
|
lines.each_with_index do |line, count|
|
21
|
-
case line.chomp
|
21
|
+
case parsed.scrub_string(line.chomp)
|
22
22
|
when /^diff/
|
23
23
|
unless patch.empty?
|
24
24
|
parsed << Patch.new(patch.join("\n") + "\n", file: file_name)
|
@@ -28,7 +28,7 @@ module GitDiffParser
|
|
28
28
|
body = false
|
29
29
|
when /^\-\-\-/
|
30
30
|
when %r{^\+\+\+ b/(?<file_name>.*)}
|
31
|
-
file_name = Regexp.last_match[:file_name]
|
31
|
+
file_name = Regexp.last_match[:file_name].rstrip
|
32
32
|
body = true
|
33
33
|
when /^(?<body>[\ @\+\-\\].*)/
|
34
34
|
patch << Regexp.last_match[:body] if body
|
@@ -42,6 +42,15 @@ module GitDiffParser
|
|
42
42
|
parsed
|
43
43
|
end
|
44
44
|
|
45
|
+
# @return [String]
|
46
|
+
def scrub_string(line)
|
47
|
+
if RUBY_VERSION >= '2.1'
|
48
|
+
line.scrub
|
49
|
+
else
|
50
|
+
line.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
45
54
|
# @return [Patches<Patch>]
|
46
55
|
def initialize(*args)
|
47
56
|
super Array.new(*args)
|
data/lib/git_diff_parser.rb
CHANGED
File without changes
|
data/package.json
CHANGED
data/thoughtbot-hound/LICENSE
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_diff_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sanemat
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -60,11 +60,11 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".conventional-changelog.context.js"
|
63
|
+
- ".github/workflows/ci.yaml"
|
63
64
|
- ".gitignore"
|
64
65
|
- ".rspec"
|
65
66
|
- ".rubocop.yml"
|
66
67
|
- ".tachikoma.yml"
|
67
|
-
- ".travis.yml"
|
68
68
|
- CODE_OF_CONDUCT.md
|
69
69
|
- Gemfile
|
70
70
|
- LICENSE.txt
|
@@ -101,10 +101,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
|
-
|
105
|
-
rubygems_version: 2.5.1
|
104
|
+
rubygems_version: 3.1.6
|
106
105
|
signing_key:
|
107
106
|
specification_version: 4
|
108
107
|
summary: Parse `git diff` into patches and lines.
|
109
108
|
test_files: []
|
110
|
-
has_rdoc:
|
data/.travis.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
language: "ruby"
|
2
|
-
sudo: false
|
3
|
-
rvm:
|
4
|
-
- "1.9"
|
5
|
-
- "2.0"
|
6
|
-
- "2.1.10"
|
7
|
-
- "2.2.5"
|
8
|
-
- "2.3.1"
|
9
|
-
- "ruby-head"
|
10
|
-
matrix:
|
11
|
-
allow_failures:
|
12
|
-
- rvm: "ruby-head"
|
13
|
-
before_install:
|
14
|
-
- "gem update bundler"
|
15
|
-
- "bin/setup"
|
16
|
-
notifications:
|
17
|
-
email:
|
18
|
-
- ogataken@gmail.com
|