colorls 1.2.1.pre.598 → 1.2.1.pre.600
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/lib/colorls/core.rb +8 -12
- data/lib/colorls/git.rb +25 -6
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1cce6a6d2fc6e45ce4fcc87135a13edc7442ab041475339d2b89b1e14c3bce94
|
|
4
|
+
data.tar.gz: 954dccdc0786131ceb3fc23d70679bafd7877868344a516ed9d00a897afb0883
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f8409394b3bb49344b1231a671966be47dc97deef8909bbac0611db39e83475574288e14f539a9f11bdd995008e7569fa3df51b885ee12fc2ec92f325e843a30
|
|
7
|
+
data.tar.gz: 22987f1296da307242ca4b9709345c9c64979f3a2f59feb1d6e238a2afdc2372f00a2a2f2e04a68fe25419b4676c977d64ab8929d9f60386d339d6a799c2c4cf
|
data/lib/colorls/core.rb
CHANGED
|
@@ -247,23 +247,19 @@ module ColorLS
|
|
|
247
247
|
def git_file_info(path)
|
|
248
248
|
return ' ✓ '.colorize(@colors[:unchanged]) unless @git_status[path]
|
|
249
249
|
|
|
250
|
-
Git.colored_status_symbols(@git_status[path]
|
|
250
|
+
Git.colored_status_symbols(@git_status[path], @colors)
|
|
251
251
|
end
|
|
252
252
|
|
|
253
253
|
def git_dir_info(path)
|
|
254
|
-
|
|
254
|
+
modes = if path == '.'
|
|
255
|
+
Set.new(@git_status.values).flatten
|
|
256
|
+
else
|
|
257
|
+
@git_status.fetch(path, nil)
|
|
258
|
+
end
|
|
255
259
|
|
|
256
|
-
|
|
260
|
+
return Git.colored_status_symbols(modes, @colors) unless modes.nil?
|
|
257
261
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
prefix = path == '.' ? '' : path + '/'
|
|
261
|
-
|
|
262
|
-
modes = @git_status.select { |file, mode| file.start_with?(prefix) && mode != '!!' }.values
|
|
263
|
-
|
|
264
|
-
return ' ✓ '.colorize(@colors[:unchanged]) if modes.empty?
|
|
265
|
-
|
|
266
|
-
Git.colored_status_symbols(modes.join.uniq, @colors)
|
|
262
|
+
' '
|
|
267
263
|
end
|
|
268
264
|
|
|
269
265
|
def long_info(content)
|
data/lib/colorls/git.rb
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'pathname'
|
|
4
|
+
|
|
3
5
|
module ColorLS
|
|
4
6
|
module Git
|
|
5
7
|
def self.status(repo_path)
|
|
6
|
-
prefix =
|
|
8
|
+
prefix = git_prefix(repo_path)
|
|
7
9
|
|
|
8
10
|
return unless $CHILD_STATUS.success?
|
|
9
11
|
|
|
10
|
-
prefix.chomp
|
|
11
|
-
|
|
12
|
+
prefix = Pathname.new(prefix.chomp)
|
|
13
|
+
|
|
14
|
+
git_status = Hash.new { |hash, key| hash[key] = Set.new }
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
git_subdir_status(repo_path) do |output|
|
|
14
17
|
while (status_line = output.gets "\x0")
|
|
15
18
|
mode, file = status_line.chomp("\x0").split(' ', 2)
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
path = Pathname.new(file).relative_path_from(prefix)
|
|
21
|
+
|
|
22
|
+
git_status[path.descend.first.cleanpath.to_s].add(mode)
|
|
18
23
|
|
|
19
24
|
# skip the next \x0 separated original path for renames, issue #185
|
|
20
25
|
output.gets("\x0") if mode.start_with? 'R'
|
|
@@ -26,7 +31,9 @@ module ColorLS
|
|
|
26
31
|
end
|
|
27
32
|
|
|
28
33
|
def self.colored_status_symbols(modes, colors)
|
|
29
|
-
|
|
34
|
+
return ' ✓ '.colorize(colors[:unchanged]) if modes.empty?
|
|
35
|
+
|
|
36
|
+
modes = modes.to_a.join.uniq.rjust(3).ljust(4)
|
|
30
37
|
|
|
31
38
|
modes
|
|
32
39
|
.gsub('?', '?'.colorize(colors[:untracked]))
|
|
@@ -35,5 +42,17 @@ module ColorLS
|
|
|
35
42
|
.gsub('D', 'D'.colorize(colors[:deletion]))
|
|
36
43
|
.tr('!', ' ')
|
|
37
44
|
end
|
|
45
|
+
|
|
46
|
+
class << self
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def git_prefix(repo_path)
|
|
50
|
+
IO.popen(['git', '-C', repo_path, 'rev-parse', '--show-prefix'], err: :close, &:gets)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def git_subdir_status(repo_path)
|
|
54
|
+
IO.popen(['git', '-C', repo_path, 'status', '--porcelain', '-z', '-unormal', '--ignored', '.'])
|
|
55
|
+
end
|
|
56
|
+
end
|
|
38
57
|
end
|
|
39
58
|
end
|
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.2.1.pre.
|
|
4
|
+
version: 1.2.1.pre.600
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Athitya Kumar
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-07-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: clocale
|