git_ls 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.leftovers.yml +2 -0
- data/.rubocop.yml +226 -0
- data/.spellr.yml +2 -0
- data/.spellr_wordlists/english.txt +33 -0
- data/.spellr_wordlists/ruby.txt +2 -0
- data/.spellr_wordlists/shell.txt +1 -0
- data/.travis.yml +6 -2
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -1
- data/README.md +3 -7
- data/Rakefile +11 -1
- data/git_index.gemspec +14 -8
- data/lib/git_ls.rb +101 -14
- data/lib/git_ls/version.rb +1 -1
- metadata +93 -4
- data/Gemfile.lock +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ef6ee0fb0ab70df2190d65de7389011c84036fff2993ebf65d90913746f7ff3
|
4
|
+
data.tar.gz: 25c8eb1f6d58e830311b531f3aedb5f5302801bec42aded9e3df8d8e06f938a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31f293dba3526adcad121f36dd7afe09ca114a559581566e25ea6f60b071c566f29840aa2be46b61f6c3291f3da896b81f9b199e341ea535bb25695ae67381e8
|
7
|
+
data.tar.gz: 79401fdfd2f6ac2497f3554ceff5d27b9e690f31e2395dbf84a429f4ae8b2c257cd3c6a4cff35f3f5768f662566951edb1e28f59b8efe4abeb22f4ca9569b922
|
data/.gitignore
CHANGED
data/.leftovers.yml
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,226 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
# Reference:
|
4
|
+
# https://rubocop.readthedocs.io/en/latest/
|
5
|
+
|
6
|
+
# Keep this in alphabetical order.
|
7
|
+
# Each override should have a comment (even if it's just "default is bad")
|
8
|
+
|
9
|
+
AllCops:
|
10
|
+
NewCops: enable
|
11
|
+
Exclude:
|
12
|
+
- db/schema*
|
13
|
+
- .bundle/**/*
|
14
|
+
- tmp/**/*
|
15
|
+
- vendor/**/*
|
16
|
+
DisplayCopNames: true
|
17
|
+
DisplayStyleGuide: true
|
18
|
+
TargetRubyVersion: 2.4
|
19
|
+
|
20
|
+
# all of our layout customisations are because we prefer indentation to be
|
21
|
+
# always consistently 2 spaces, for blocks, scopes, multiline expressions, etc
|
22
|
+
# e.g.
|
23
|
+
# class Klass
|
24
|
+
# def method(arg1,
|
25
|
+
# arg2)
|
26
|
+
# value = if arg1 == 'value' && arg2 == 'value'
|
27
|
+
# method2
|
28
|
+
# .method(arg_a, arg_b,
|
29
|
+
# arg_c, arg_d, keyword1: true,
|
30
|
+
# keyword2: true) do
|
31
|
+
# @last = [
|
32
|
+
# arg_a, arg_b,
|
33
|
+
# arg_c, arg_d
|
34
|
+
# ]
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
# value
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
|
41
|
+
# to match our preference for consistent indentation
|
42
|
+
Layout/HashAlignment:
|
43
|
+
EnforcedLastArgumentHashStyle: always_ignore
|
44
|
+
|
45
|
+
# to match our preference for consistent indentation
|
46
|
+
Layout/ParameterAlignment:
|
47
|
+
EnforcedStyle: with_fixed_indentation
|
48
|
+
|
49
|
+
# to match our preference for consistent indentation
|
50
|
+
Layout/BlockAlignment:
|
51
|
+
EnforcedStyleAlignWith: start_of_block
|
52
|
+
|
53
|
+
# to match our preference for consistent indentation
|
54
|
+
Layout/CaseIndentation:
|
55
|
+
EnforcedStyle: end
|
56
|
+
|
57
|
+
# to match our preference for consistent indentation
|
58
|
+
Layout/EndAlignment:
|
59
|
+
EnforcedStyleAlignWith: start_of_line
|
60
|
+
|
61
|
+
# Aligning Assignments, etc makes diffs noisy
|
62
|
+
Layout/ExtraSpacing:
|
63
|
+
AllowForAlignment: false
|
64
|
+
|
65
|
+
# to match our preference for consistent indentation
|
66
|
+
Layout/FirstArrayElementLineBreak:
|
67
|
+
Enabled: true
|
68
|
+
|
69
|
+
# to match our preference for consistent indentation
|
70
|
+
Layout/FirstHashElementLineBreak:
|
71
|
+
Enabled: true
|
72
|
+
|
73
|
+
# to match our preference for consistent indentation
|
74
|
+
Layout/FirstArgumentIndentation:
|
75
|
+
EnforcedStyle: consistent
|
76
|
+
|
77
|
+
# to match our preference for consistent indentation
|
78
|
+
Layout/FirstArrayElementIndentation:
|
79
|
+
EnforcedStyle: consistent
|
80
|
+
|
81
|
+
# to match our preference for consistent indentation
|
82
|
+
Layout/FirstHashElementIndentation:
|
83
|
+
EnforcedStyle: consistent
|
84
|
+
|
85
|
+
Layout/LineLength:
|
86
|
+
Max: 120
|
87
|
+
|
88
|
+
# to match our preference for consistent indentation
|
89
|
+
# and hanging assignment looks lost
|
90
|
+
Layout/MultilineAssignmentLayout:
|
91
|
+
EnforcedStyle: same_line
|
92
|
+
|
93
|
+
# this changes our preferred:
|
94
|
+
# value = if thing1 &&
|
95
|
+
# thing2
|
96
|
+
# to:
|
97
|
+
# value = if thing1 &&
|
98
|
+
# thing2
|
99
|
+
# even though the IndentationWidth is 2
|
100
|
+
# but it's right most of the time so I put up with it
|
101
|
+
Layout/MultilineOperationIndentation:
|
102
|
+
EnforcedStyle: indented
|
103
|
+
|
104
|
+
Layout/MultilineMethodCallIndentation:
|
105
|
+
EnforcedStyle: indented
|
106
|
+
|
107
|
+
# Temporarily disable this spec as a recent change has broken it for us:
|
108
|
+
# https://github.com/rubocop-hq/rubocop/issues/6254
|
109
|
+
Layout/RescueEnsureAlignment:
|
110
|
+
Enabled: false
|
111
|
+
|
112
|
+
Metrics:
|
113
|
+
CountComments: false
|
114
|
+
|
115
|
+
Metrics/BlockLength:
|
116
|
+
ExcludedMethods:
|
117
|
+
- configure
|
118
|
+
- describe
|
119
|
+
- context
|
120
|
+
- shared_examples
|
121
|
+
|
122
|
+
Metrics/CyclomaticComplexity:
|
123
|
+
Enabled: false
|
124
|
+
|
125
|
+
Metrics/PerceivedComplexity:
|
126
|
+
Enabled: false
|
127
|
+
|
128
|
+
RSpec:
|
129
|
+
Enabled: true
|
130
|
+
Include:
|
131
|
+
- 'spec/**/*.rb'
|
132
|
+
|
133
|
+
RSpec/DescribeClass:
|
134
|
+
Enabled: false
|
135
|
+
|
136
|
+
RSpec/ExampleLength:
|
137
|
+
Enabled: false
|
138
|
+
|
139
|
+
# I misuse matchers often
|
140
|
+
RSpec/ExpectActual:
|
141
|
+
Enabled: false
|
142
|
+
|
143
|
+
RSpec/FilePath:
|
144
|
+
Enabled: false
|
145
|
+
|
146
|
+
# Multiple expectations are useful
|
147
|
+
# checking you've partially achieved something on the way to completely achieving it is useful for debugging failures
|
148
|
+
RSpec/MultipleExpectations:
|
149
|
+
Enabled: false
|
150
|
+
|
151
|
+
# It should be obvious from context. Chill out rubocop
|
152
|
+
RSpec/NamedSubject:
|
153
|
+
Enabled: false
|
154
|
+
|
155
|
+
RSpec/NestedGroups:
|
156
|
+
Max: 7
|
157
|
+
|
158
|
+
# This matches the style we've been using all along (ever so slightly more frequently)
|
159
|
+
Style/Alias:
|
160
|
+
EnforcedStyle: prefer_alias_method
|
161
|
+
|
162
|
+
Style/CollectionMethods:
|
163
|
+
Enabled: true
|
164
|
+
|
165
|
+
# we don't rdoc
|
166
|
+
Style/Documentation:
|
167
|
+
Enabled: false
|
168
|
+
|
169
|
+
# this can mess with the balance of symmetric cases
|
170
|
+
Style/IfInsideElse:
|
171
|
+
Enabled: false
|
172
|
+
|
173
|
+
Style/GlobalVars:
|
174
|
+
Exclude:
|
175
|
+
- spec/**/*
|
176
|
+
|
177
|
+
# [a, b].include?(x) is more unclear than a == x || b == x
|
178
|
+
Style/MultipleComparison:
|
179
|
+
Enabled: false
|
180
|
+
|
181
|
+
# it's microscopically faster
|
182
|
+
Style/Not:
|
183
|
+
Enabled: false
|
184
|
+
|
185
|
+
Style/GuardClause:
|
186
|
+
Enabled: false
|
187
|
+
|
188
|
+
# we use %w{} pretty frequently
|
189
|
+
Style/PercentLiteralDelimiters:
|
190
|
+
PreferredDelimiters:
|
191
|
+
default: '{}'
|
192
|
+
'%w': '{}'
|
193
|
+
'%W': '{}'
|
194
|
+
'%i': '{}'
|
195
|
+
'%I': '{}'
|
196
|
+
'%r': '{}'
|
197
|
+
|
198
|
+
# We want this to warn to force consistency within the codebase.
|
199
|
+
Style/SafeNavigation:
|
200
|
+
Enabled: true
|
201
|
+
|
202
|
+
# different methods calls that do exactly the same thing are a smell, regardless of semantics
|
203
|
+
Style/SignalException:
|
204
|
+
EnforcedStyle: only_raise
|
205
|
+
|
206
|
+
# this wants less descriptive names
|
207
|
+
Style/SingleLineBlockParams:
|
208
|
+
Enabled: false
|
209
|
+
|
210
|
+
Style/SymbolArray:
|
211
|
+
Enabled: false
|
212
|
+
|
213
|
+
Style/WordArray:
|
214
|
+
Enabled: false
|
215
|
+
|
216
|
+
Style/HashEachMethods:
|
217
|
+
Enabled: true
|
218
|
+
|
219
|
+
Style/HashTransformKeys:
|
220
|
+
Enabled: true
|
221
|
+
|
222
|
+
Style/HashTransformValues:
|
223
|
+
Enabled: true
|
224
|
+
|
225
|
+
Style/CommentedKeyword:
|
226
|
+
Enabled: false
|
data/.spellr.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
baz
|
2
|
+
changelog
|
3
|
+
codebase
|
4
|
+
cov
|
5
|
+
customisations
|
6
|
+
cyclomatic
|
7
|
+
dirc
|
8
|
+
dircache
|
9
|
+
env
|
10
|
+
gemfile
|
11
|
+
idx
|
12
|
+
jruby
|
13
|
+
klass
|
14
|
+
msb
|
15
|
+
nocov
|
16
|
+
noninfringement
|
17
|
+
nul
|
18
|
+
nuls
|
19
|
+
params
|
20
|
+
pwd
|
21
|
+
quotepath
|
22
|
+
rdoc
|
23
|
+
rspec
|
24
|
+
rubo
|
25
|
+
rubocop
|
26
|
+
rvm
|
27
|
+
sharedindex
|
28
|
+
sherson
|
29
|
+
simplecov
|
30
|
+
sudo
|
31
|
+
tmp
|
32
|
+
usr
|
33
|
+
yardoc
|
@@ -0,0 +1 @@
|
|
1
|
+
euo
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
Parses the .git/index file like `git ls-files` does.
|
4
4
|
|
5
5
|
- for small repos (as in, anything smaller than rails),
|
6
|
-
it can be
|
7
|
-
- still takes less than half a second for large repos e.g. the linux repo
|
6
|
+
it can be faster than doing the system call to git
|
7
|
+
- still takes less than half a second for very large repos e.g. the linux repo
|
8
8
|
- doesn't require git to be installed
|
9
9
|
|
10
10
|
## Installation
|
@@ -28,10 +28,6 @@ Or install it yourself as:
|
|
28
28
|
`GitLS.files` returns an array of filenames, equivalent to `` `git ls-files -z`.split("\0") ``
|
29
29
|
`GitLS.files("path/to/repo")` if the repo is not $PWD.
|
30
30
|
|
31
|
-
## Issues
|
32
|
-
|
33
|
-
- Doesn't understand split index files at all
|
34
|
-
|
35
31
|
## Development
|
36
32
|
|
37
33
|
Have a look in the bin dir for some useful tools.
|
@@ -40,7 +36,7 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
40
36
|
## Contributing
|
41
37
|
|
42
38
|
Bug reports and pull requests are welcome on GitHub at https://github.com/robotdana/git_ls.
|
43
|
-
If you're comfortable, please attach `.git/index` and the output of `git ls-files` where it doesn't match.
|
39
|
+
If you're comfortable, please attach `.git/index` (and `.git/sharedindex.<sha>` if applicable) and the output of `git ls-files` where it doesn't match.
|
44
40
|
|
45
41
|
|
46
42
|
## License
|
data/Rakefile
CHANGED
@@ -2,7 +2,17 @@
|
|
2
2
|
|
3
3
|
require 'bundler/gem_tasks'
|
4
4
|
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
require 'spellr/rake_task'
|
7
|
+
require 'leftovers/rake_task'
|
5
8
|
|
9
|
+
RuboCop::RakeTask.new
|
6
10
|
RSpec::Core::RakeTask.new(:spec)
|
11
|
+
Spellr::RakeTask.generate_task
|
12
|
+
Leftovers::RakeTask.generate_task
|
7
13
|
|
8
|
-
|
14
|
+
if RUBY_PLATFORM == 'java'
|
15
|
+
task default: %i{spec build}
|
16
|
+
else
|
17
|
+
task default: %i{spec rubocop spellr leftovers build}
|
18
|
+
end
|
data/git_index.gemspec
CHANGED
@@ -3,20 +3,20 @@
|
|
3
3
|
require_relative 'lib/git_ls/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
6
|
+
spec.name = 'git_ls'
|
7
|
+
spec.version = GitLS::VERSION
|
8
|
+
spec.authors = ['Dana Sherson']
|
9
|
+
spec.email = ['robot@dana.sh']
|
10
10
|
|
11
|
-
spec.summary
|
12
|
-
spec.homepage
|
13
|
-
spec.license
|
11
|
+
spec.summary = 'Read a .git/index file and list the files'
|
12
|
+
spec.homepage = 'https://github.com/robotdana/git_ls'
|
13
|
+
spec.license = 'MIT'
|
14
14
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
|
15
15
|
|
16
16
|
if spec.respond_to?(:metadata)
|
17
17
|
spec.metadata['homepage_uri'] = spec.homepage
|
18
18
|
spec.metadata['source_code_uri'] = spec.homepage
|
19
|
-
spec.metadata['changelog_uri'] = spec.homepage
|
19
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
20
20
|
end
|
21
21
|
|
22
22
|
# Specify which files should be added to the gem when it is released.
|
@@ -28,6 +28,12 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
|
30
30
|
spec.add_development_dependency 'bundler', '>= 2'
|
31
|
+
spec.add_development_dependency 'leftovers'
|
31
32
|
spec.add_development_dependency 'pry', '> 0'
|
33
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
34
|
+
spec.add_development_dependency 'rubocop'
|
35
|
+
spec.add_development_dependency 'rubocop-performance'
|
36
|
+
spec.add_development_dependency 'rubocop-rspec'
|
32
37
|
spec.add_development_dependency 'simplecov', '~> 0.18.5'
|
38
|
+
spec.add_development_dependency 'spellr'
|
33
39
|
end
|
data/lib/git_ls.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Usage:
|
4
4
|
# GitLS.files -> Array of strings as files.
|
5
5
|
# This will be identical output to git ls-files
|
6
|
-
module GitLS
|
6
|
+
module GitLS # rubocop:disable Metrics/ModuleLength
|
7
7
|
class Error < StandardError; end
|
8
8
|
|
9
9
|
class << self
|
@@ -15,31 +15,34 @@ module GitLS
|
|
15
15
|
read(path, true)
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
private
|
19
19
|
|
20
|
-
def read(path, return_headers_only)
|
20
|
+
def read(path, return_headers_only) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
21
21
|
path = ::File.join(path, '.git/index') if ::File.directory?(path)
|
22
22
|
file = ::File.new(path)
|
23
|
+
buf = ::String.new
|
23
24
|
# 4-byte signature:
|
24
25
|
# The signature is { 'D', 'I', 'R', 'C' } (stands for "dircache")
|
25
26
|
# 4-byte version number:
|
26
27
|
# The current supported versions are 2, 3 and 4.
|
27
28
|
# 32-bit number of index entries.
|
28
|
-
sig, git_index_version, length = file.read(12).unpack('
|
29
|
-
raise ::GitLS::Error,
|
29
|
+
sig, git_index_version, length = file.read(12, buf).unpack('a4NN')
|
30
|
+
raise ::GitLS::Error, ".git/index file not found at #{path}" unless sig == 'DIRC'
|
30
31
|
|
31
32
|
return { git_index_version: git_index_version, length: length } if return_headers_only
|
32
33
|
|
33
|
-
files = Array.new(length)
|
34
|
+
files = ::Array.new(length)
|
34
35
|
case git_index_version
|
35
36
|
when 2 then files_2(files, file)
|
36
37
|
when 3 then files_3(files, file)
|
37
38
|
when 4 then files_4(files, file)
|
38
39
|
else raise ::GitLS::Error, 'Unrecognized git index version'
|
39
40
|
end
|
41
|
+
|
42
|
+
extensions(files, file, buf)
|
40
43
|
files
|
41
|
-
rescue Errno::ENOENT => e
|
42
|
-
raise GitLS::Error, "Not a git directory: #{e.message}"
|
44
|
+
rescue ::Errno::ENOENT => e
|
45
|
+
raise ::GitLS::Error, "Not a git directory: #{e.message}"
|
43
46
|
ensure
|
44
47
|
# :nocov:
|
45
48
|
# coverage tracking for branches in ensure blocks is weird
|
@@ -48,12 +51,96 @@ module GitLS
|
|
48
51
|
files
|
49
52
|
end
|
50
53
|
|
51
|
-
|
54
|
+
def extensions(files, file, buf)
|
55
|
+
case file.read(4, buf)
|
56
|
+
when 'link' then link_extension(files, file, buf)
|
57
|
+
when /[A-Z]{4}/ then ignored_extension(files, file, buf)
|
58
|
+
else
|
59
|
+
return if (file.pos += 16) && file.eof?
|
60
|
+
|
61
|
+
raise ::GitLS::Error, "Unrecognized .git/index extension #{buf.inspect}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def ignored_extension(files, file, buf)
|
66
|
+
size = file.read(4, buf).unpack1('N')
|
67
|
+
file.pos += size
|
68
|
+
extensions(files, file, buf)
|
69
|
+
end
|
70
|
+
|
71
|
+
def link_extension(files, file, buf) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
72
|
+
file.pos += 4 # size = file.read(4, buf).unpack1('N')
|
73
|
+
|
74
|
+
sha = file.read(20, buf)
|
75
|
+
|
76
|
+
new_files = files.dup
|
77
|
+
|
78
|
+
files.replace files("#{::File.dirname(file.path)}/sharedindex.#{sha.unpack1('H*')}")
|
79
|
+
|
80
|
+
ewah_each_value(file, buf) do |pos|
|
81
|
+
files[pos] = nil
|
82
|
+
end
|
83
|
+
|
84
|
+
ewah_each_value(file, buf) do |pos|
|
85
|
+
replacement_file = new_files.shift
|
86
|
+
# the documentation *implies* that this *may* get a new filename
|
87
|
+
# i can't get it to happen though
|
88
|
+
# :nocov:
|
89
|
+
files[pos] = replacement_file unless replacement_file.empty?
|
90
|
+
# :nocov:
|
91
|
+
end
|
92
|
+
|
93
|
+
files.compact!
|
94
|
+
files.concat(new_files)
|
95
|
+
files.sort!
|
96
|
+
|
97
|
+
extensions(files, file, buf)
|
98
|
+
end
|
99
|
+
|
100
|
+
# format is defined here:
|
101
|
+
# https://git-scm.com/docs/bitmap-format#_appendix_a_serialization_format_for_an_ewah_bitmap
|
102
|
+
def ewah_each_value(file, buf) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
103
|
+
uncompressed_pos = 0
|
104
|
+
file.pos += 4 # uncompressed_bits_count = file.read(4, buf).unpack1('N')
|
105
|
+
compressed_bytes = file.read(4, buf).unpack1('N') * 8
|
106
|
+
|
107
|
+
final_file_pos = file.pos + compressed_bytes
|
108
|
+
|
109
|
+
until file.pos == final_file_pos
|
110
|
+
run_length_word = file.read(8, buf).unpack1('Q>')
|
111
|
+
# 1st bit
|
112
|
+
run_bit = run_length_word & 1
|
113
|
+
# the next 32 bits, masked, multiplied by 64 (which is shifted by 6 places)
|
114
|
+
run_length = ((run_length_word >> 1) & 0xFFFF_FFFF) << 6
|
115
|
+
# the next 31 bits
|
116
|
+
literal_length = (run_length_word >> 33)
|
117
|
+
|
118
|
+
if run_bit == 1
|
119
|
+
run_length.times do
|
120
|
+
yield uncompressed_pos
|
121
|
+
uncompressed_pos += 1
|
122
|
+
end
|
123
|
+
else
|
124
|
+
uncompressed_pos += run_length
|
125
|
+
end
|
126
|
+
|
127
|
+
literal_length.times do
|
128
|
+
word = file.read(8, buf).unpack1('B*').reverse
|
129
|
+
word.each_char do |char|
|
130
|
+
yield(uncompressed_pos) if char == '1'
|
131
|
+
|
132
|
+
uncompressed_pos += 1
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
file.pos += 4 # bitmap metadata for adding to bitmaps
|
138
|
+
end
|
52
139
|
|
53
|
-
def files_2(files, file)
|
140
|
+
def files_2(files, file) # rubocop:disable Metrics/MethodLength
|
54
141
|
files.map! do
|
55
142
|
file.pos += 60 # skip 60 bytes (40 bytes of stat, 20 bytes of sha)
|
56
|
-
length = (file.getbyte & 0b0000_1111)
|
143
|
+
length = ((file.getbyte & 0b0000_1111) << 8) + file.getbyte # find the 12 byte length
|
57
144
|
if length < 0xFFF
|
58
145
|
path = file.read(length)
|
59
146
|
# :nocov:
|
@@ -68,7 +155,7 @@ module GitLS
|
|
68
155
|
end
|
69
156
|
end
|
70
157
|
|
71
|
-
def files_3(files, file)
|
158
|
+
def files_3(files, file) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
72
159
|
files.map! do
|
73
160
|
file.pos += 60 # skip 60 bytes (40 bytes of stat, 20 bytes of sha)
|
74
161
|
|
@@ -92,8 +179,8 @@ module GitLS
|
|
92
179
|
end
|
93
180
|
end
|
94
181
|
|
95
|
-
def files_4(files, file)
|
96
|
-
prev_entry_path =
|
182
|
+
def files_4(files, file) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
183
|
+
prev_entry_path = ''
|
97
184
|
files.map! do
|
98
185
|
file.pos += 60 # skip 60 bytes (40 bytes of stat, 20 bytes of sha)
|
99
186
|
flags = file.getbyte * 256 + file.getbyte
|
data/lib/git_ls/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_ls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dana Sherson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: leftovers
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: pry
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +52,62 @@ dependencies:
|
|
38
52
|
- - ">"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 12.3.3
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 12.3.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-performance
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
41
111
|
- !ruby/object:Gem::Dependency
|
42
112
|
name: simplecov
|
43
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +122,20 @@ dependencies:
|
|
52
122
|
- - "~>"
|
53
123
|
- !ruby/object:Gem::Version
|
54
124
|
version: 0.18.5
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: spellr
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
55
139
|
description:
|
56
140
|
email:
|
57
141
|
- robot@dana.sh
|
@@ -60,12 +144,17 @@ extensions: []
|
|
60
144
|
extra_rdoc_files: []
|
61
145
|
files:
|
62
146
|
- ".gitignore"
|
147
|
+
- ".leftovers.yml"
|
63
148
|
- ".rspec"
|
149
|
+
- ".rubocop.yml"
|
64
150
|
- ".simplecov"
|
151
|
+
- ".spellr.yml"
|
152
|
+
- ".spellr_wordlists/english.txt"
|
153
|
+
- ".spellr_wordlists/ruby.txt"
|
154
|
+
- ".spellr_wordlists/shell.txt"
|
65
155
|
- ".travis.yml"
|
66
156
|
- CHANGELOG.md
|
67
157
|
- Gemfile
|
68
|
-
- Gemfile.lock
|
69
158
|
- LICENSE.txt
|
70
159
|
- README.md
|
71
160
|
- Rakefile
|
@@ -94,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
183
|
- !ruby/object:Gem::Version
|
95
184
|
version: '0'
|
96
185
|
requirements: []
|
97
|
-
rubygems_version: 3.
|
186
|
+
rubygems_version: 3.0.3
|
98
187
|
signing_key:
|
99
188
|
specification_version: 4
|
100
189
|
summary: Read a .git/index file and list the files
|
data/Gemfile.lock
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
git_ls (0.3.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
coderay (1.1.3)
|
10
|
-
diff-lcs (1.4.4)
|
11
|
-
docile (1.3.2)
|
12
|
-
method_source (1.0.0)
|
13
|
-
pry (0.13.1)
|
14
|
-
coderay (~> 1.1)
|
15
|
-
method_source (~> 1.0)
|
16
|
-
rake (12.3.3)
|
17
|
-
rspec (3.9.0)
|
18
|
-
rspec-core (~> 3.9.0)
|
19
|
-
rspec-expectations (~> 3.9.0)
|
20
|
-
rspec-mocks (~> 3.9.0)
|
21
|
-
rspec-core (3.9.2)
|
22
|
-
rspec-support (~> 3.9.3)
|
23
|
-
rspec-expectations (3.9.2)
|
24
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
-
rspec-support (~> 3.9.0)
|
26
|
-
rspec-mocks (3.9.1)
|
27
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
-
rspec-support (~> 3.9.0)
|
29
|
-
rspec-support (3.9.3)
|
30
|
-
simplecov (0.18.5)
|
31
|
-
docile (~> 1.1)
|
32
|
-
simplecov-html (~> 0.11)
|
33
|
-
simplecov-html (0.12.2)
|
34
|
-
|
35
|
-
PLATFORMS
|
36
|
-
ruby
|
37
|
-
|
38
|
-
DEPENDENCIES
|
39
|
-
bundler (>= 2)
|
40
|
-
git_ls!
|
41
|
-
pry (> 0)
|
42
|
-
rake (~> 12.0)
|
43
|
-
rspec (~> 3.0)
|
44
|
-
simplecov (~> 0.18.5)
|
45
|
-
|
46
|
-
BUNDLED WITH
|
47
|
-
2.1.4
|