colorls 1.1.0 → 1.1.1

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: baadf69e664b9bab7c78f96af16d833f7d03302c
4
- data.tar.gz: e72d0b65aefd804aec27dab9865fb9066e9c56d1
3
+ metadata.gz: 8c4e2dd3d9823e5c27fe6a41124dfc6511320df5
4
+ data.tar.gz: 6ec38c1e754d1435363e03c4f86a6533e062f408
5
5
  SHA512:
6
- metadata.gz: 5234ec2b037d9b50f82eac2cfdec97b0befc6f25f563fecd55a25b0f312b6b54acfe9ff573c73a636e6902b2e08dfba8cdff8d89e41182733d9d700a1b07ba10
7
- data.tar.gz: b6d1d437c80186e03850a8c184892b78cf98ecd261ac41820033a294e3899a671eb0b0d96f4fccdfa6322149653945cd3f9f64ee65611353e80ad9f9e4983eb9
6
+ metadata.gz: 74cca11860e9251eb41d953f0d98fb40f7b8e0b9ad189c9b1a4c258a277cc4d9849a5c361b80e36d86255ad72d3f6f6a08aea980a97e5a9997096a7223cbcf1d
7
+ data.tar.gz: 2c8cd7f0c111826a0a257b2122cdcceda32dc02c7dafcd880fa3f461a92e447368f02815a3c67ec9c9810718fe343e4c31473cd996848c3fa12d01841e6c1cb9
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'colorls/version'
4
4
 
@@ -218,45 +218,35 @@ module ColorLS
218
218
  def git_info(path, content)
219
219
  return '' unless @git_status
220
220
 
221
- # puts "\n\n"
221
+ real_path = File.realdirpath(content.name, path)
222
+
223
+ return ' ' unless real_path.start_with? path
222
224
 
223
- relative_path = path.remove(@git_root_path+'/')
224
- relative_path = relative_path==path ? '' : relative_path+'/'
225
- content_path = "#{relative_path}#{content}"
225
+ relative_path = real_path.remove(Regexp.new('^' + Regexp.escape(@git_root_path) + '/?'))
226
226
 
227
227
  if content.directory?
228
- git_dir_info(content_path)
228
+ git_dir_info(relative_path)
229
229
  else
230
- git_file_info(content_path)
230
+ git_file_info(relative_path)
231
231
  end
232
232
  # puts "\n\n"
233
233
  end
234
234
 
235
235
  def git_file_info(path)
236
236
  return ' ✓ '.colorize(@colors[:unchanged]) unless @git_status[path]
237
- Git.colored_status_symbols(@git_status[path], @colors)
238
- end
239
-
240
- Dir.class_eval do
241
- def self.deep_entries(path)
242
- (Dir.entries(path) - ['.', '..']).map do |entry|
243
- if Dir.exist?("#{path}/#{entry}")
244
- Dir.deep_entries("#{path}/#{entry}")
245
- else
246
- entry
247
- end
248
- end.flatten
249
- end
237
+ Git.colored_status_symbols(@git_status[path].uniq, @colors)
250
238
  end
251
239
 
252
240
  def git_dir_info(path)
253
- ignored = @git_status.select { |file, mode| file.start_with?(path) && mode=='!!' }.keys
254
- present = Dir.deep_entries(path).map { |p| "#{path}/#{p}" }
255
- return ' ' if (present-ignored).empty?
241
+ direct_status = @git_status.fetch("#{path}/", nil)
242
+
243
+ return Git.colored_status_symbols(direct_status.uniq, @colors) unless direct_status.nil?
244
+
245
+ modes = @git_status.select { |file, mode| file.start_with?(path) && mode != '!!' }
256
246
 
257
- modes = (present-ignored).map { |file| @git_status[file] }-[nil]
258
247
  return ' ✓ '.colorize(@colors[:unchanged]) if modes.empty?
259
- Git.colored_status_symbols(modes.join.uniq, @colors)
248
+
249
+ Git.colored_status_symbols(modes.values.join.uniq, @colors)
260
250
  end
261
251
 
262
252
  def long_info(content)
@@ -3,9 +3,14 @@ module ColorLS
3
3
  def self.status(repo_path)
4
4
  @git_status = {}
5
5
 
6
- IO.popen(['git', '-C', repo_path, 'status', '--porcelain', '-z', '-uall', '--ignored']) do |output|
7
- output.read.split("\x0").map { |x| x.split(' ', 2) }.each do |mode, file|
6
+ IO.popen(['git', '-C', repo_path, 'status', '--porcelain', '-z', '-unormal', '--ignored']) do |output|
7
+ while (status_line = output.gets "\x0")
8
+ mode, file = status_line.chomp("\x0").split(' ', 2)
9
+
8
10
  @git_status[file] = mode
11
+
12
+ # skip the next \x0 separated original path for renames, issue #185
13
+ output.gets("\x0") if mode.start_with? 'R'
9
14
  end
10
15
  end
11
16
  warn "git status failed in #{repo_path}" unless $CHILD_STATUS.success?
@@ -14,13 +19,7 @@ module ColorLS
14
19
  end
15
20
 
16
21
  def self.colored_status_symbols(modes, colors)
17
- modes =
18
- case modes.length
19
- when 1 then " #{modes} "
20
- when 2 then " #{modes} "
21
- when 3 then "#{modes} "
22
- when 4 then modes
23
- end
22
+ modes = modes.rjust(3).ljust(4)
24
23
 
25
24
  modes
26
25
  .gsub('?', '?'.colorize(colors[:untracked]))
@@ -1,3 +1,3 @@
1
1
  module ColorLS
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.1.1'.freeze
3
3
  end
@@ -2,8 +2,11 @@ apk: android
2
2
  gradle: android
3
3
  ds_store: apple
4
4
  localized: apple
5
+ flac: audio
6
+ m4a: audio
5
7
  mp3: audio
6
8
  ogg: audio
9
+ wav: audio
7
10
  editorconfig: conf
8
11
  scss: css
9
12
  docx: doc
@@ -24,7 +27,10 @@ ico: image
24
27
  jpeg: image
25
28
  jpg: image
26
29
  png: image
30
+ pxm: image
27
31
  svg: image
32
+ tiff: image
33
+ webp: image
28
34
  jar: java
29
35
  properties: json
30
36
  tsx: jsx
@@ -35,6 +41,7 @@ rdoc: md
35
41
  readme: md
36
42
  gslides: ppt
37
43
  pptx: ppt
44
+ ipynb: py
38
45
  pyc: py
39
46
  rdata: r
40
47
  rds: r
@@ -62,7 +69,9 @@ zshrc: shell
62
69
  stylus: styl
63
70
  cls: tex
64
71
  avi: video
72
+ flv: video
65
73
  mkv: video
74
+ mov: video
66
75
  mp4: video
67
76
  ogv: video
68
77
  webm: video
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colorls
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Athitya Kumar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-15 00:00:00.000000000 Z
11
+ date: 2018-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clocale