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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36c6e6d61f60fe176e7572301535d5368577d4e1
4
- data.tar.gz: 3f5c8d4371cbed33fbb57228215af0a1489471b8
3
+ metadata.gz: 52dbec81b82c6356e2c62eaa606a85246c76cc7f
4
+ data.tar.gz: bcadbad61f03381f7733f3292fd1836b11ee0688
5
5
  SHA512:
6
- metadata.gz: 1bdccffa9f74e689fb437770c6f0143bc9b608e24ddf759095281b7d54347462ec482ee7da9bda43dbd25c5ffe284344db5f3aef340b0ae019a4b15bbd42d284
7
- data.tar.gz: f1d4d448f5d2c9d81d79902502931504d517e1f23b31bcff7cf3af87505532af8c187c47afe45921834762642388f73017c755124fe68c9d6db3b86dbae833e5
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-newline-at-eof [options]
137
- -f, --feed-last-line Add newline to line what is not terminated by newline at end of file.
138
- -d, --discard-last-newline Remove discarded newline at end of file.
139
- -a, --treat-all This is identical with --feed-last-line --discard-last-newline.
140
- -c, --check-all Check and show warning about newline at end of file.
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
- [![Build Status](https://travis-ci.org/aycabta/git-newline-at-eof.svg)](https://travis-ci.org/aycabta/git-newline-at-eof)
168
+ - [![Build Status](https://travis-ci.org/aycabta/git-newline-at-eof.svg)](https://travis-ci.org/aycabta/git-newline-at-eof)
169
+ - [![Build Status](https://ci.appveyor.com/api/projects/status/github/aycabta/git-newline-at-eof?branch=master&svg=true)](https://ci.appveyor.com/project/aycabta/git-newline-at-eof)
@@ -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"
@@ -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").map { |filename|
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, 'rt') { |f| count_last_newlines(f) }
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
@@ -1,3 +1,3 @@
1
1
  module GitNewlineAtEof
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  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.2
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-01 00:00:00.000000000 Z
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