git-newline-at-eof 0.1.2 → 0.1.3
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 +9 -6
- data/appveyor.yml +13 -0
- data/lib/git-newline-at-eof.rb +15 -3
- data/lib/git-newline-at-eof/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52dbec81b82c6356e2c62eaa606a85246c76cc7f
|
4
|
+
data.tar.gz: bcadbad61f03381f7733f3292fd1836b11ee0688
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12563f3d33eef269da7a5bd6beae3b488b43054c0f180195f2ea6ed14fbb8a55db85f842fb6743f1d0f76ddeb77e3d0d792dbd6b050b5ba6b48f65aeb96165a9
|
7
|
+
data.tar.gz: 28bc68fa388e4218add3496e2815292b3667ebea6998e00ef57786f5bb21921ddde76decdff33d2ed65bcfb4bb84819eb91433bb813854eff38e08885b0e8b13
|
data/README.md
CHANGED
@@ -133,11 +133,13 @@ Help.
|
|
133
133
|
|
134
134
|
```bash
|
135
135
|
$ git newline-at-eof --help
|
136
|
-
Usage: git
|
137
|
-
-f, --feed-last-line
|
138
|
-
-d, --discard-last-newline
|
139
|
-
-a, --treat-all
|
140
|
-
-c, --check-all
|
136
|
+
Usage: git newline-at-eof [options]
|
137
|
+
-f, --feed-last-line Add newline to not terminated line at end of file.
|
138
|
+
-d, --discard-last-newline Remove discarded newline at end of file.
|
139
|
+
-a, --treat-all This is identical with -f -d.
|
140
|
+
-c, --check-all Check and show warning about newline at end of file.
|
141
|
+
-h, --help Show this message.
|
142
|
+
-v, --version Show version.
|
141
143
|
```
|
142
144
|
|
143
145
|
## Supported Versions
|
@@ -163,4 +165,5 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
163
165
|
|
164
166
|
## Badges
|
165
167
|
|
166
|
-
[](https://travis-ci.org/aycabta/git-newline-at-eof)
|
168
|
+
- [](https://travis-ci.org/aycabta/git-newline-at-eof)
|
169
|
+
- [](https://ci.appveyor.com/project/aycabta/git-newline-at-eof)
|
data/appveyor.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
install:
|
3
|
+
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
4
|
+
- gem install bundler --no-document
|
5
|
+
- bundle install
|
6
|
+
build: off
|
7
|
+
test_script:
|
8
|
+
- bundle exec rake
|
9
|
+
deploy: off
|
10
|
+
environment:
|
11
|
+
matrix:
|
12
|
+
- ruby_version: "23"
|
13
|
+
- ruby_version: "23-x64"
|
data/lib/git-newline-at-eof.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'git-newline-at-eof/version'
|
2
2
|
require 'optparse'
|
3
|
+
require 'shellwords'
|
3
4
|
|
4
5
|
module GitNewlineAtEof
|
5
6
|
class Application
|
@@ -176,11 +177,15 @@ module GitNewlineAtEof
|
|
176
177
|
private :discarded_newline?
|
177
178
|
|
178
179
|
def files
|
179
|
-
`git ls-files`.split("\n").
|
180
|
+
`git ls-files`.split("\n").select{ |filename|
|
181
|
+
# check text file
|
182
|
+
`git grep -I --name-only --untracked -e . -- #{Shellwords.shellescape(filename)}`
|
183
|
+
$? == 0
|
184
|
+
}.map { |filename|
|
180
185
|
filepath = current_dir(filename)
|
181
186
|
num = 0
|
182
187
|
begin
|
183
|
-
num = File.open(filepath, '
|
188
|
+
num = File.open(filepath, 'rb') { |f| count_last_newlines(f) }
|
184
189
|
rescue
|
185
190
|
num = nil
|
186
191
|
end
|
@@ -196,12 +201,19 @@ module GitNewlineAtEof
|
|
196
201
|
if f.size == 0
|
197
202
|
nil
|
198
203
|
else
|
204
|
+
prev_char = nil
|
199
205
|
count = 0
|
200
206
|
f.size.step(1, -1) do |offset|
|
201
207
|
offset -= 1
|
202
208
|
f.seek(offset, IO::SEEK_SET)
|
203
|
-
if f.getc == "\n"
|
209
|
+
if (c = f.getc) == "\n"
|
204
210
|
count += 1
|
211
|
+
prev_char = c
|
212
|
+
elsif c == "\r"
|
213
|
+
unless prev_char == "\n"
|
214
|
+
count += 1
|
215
|
+
end
|
216
|
+
prev_char = c
|
205
217
|
else
|
206
218
|
break
|
207
219
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-newline-at-eof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code Ass
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- LICENSE.txt
|
67
67
|
- README.md
|
68
68
|
- Rakefile
|
69
|
+
- appveyor.yml
|
69
70
|
- bin/console
|
70
71
|
- bin/setup
|
71
72
|
- exe/git-newline-at-eof
|