mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-19 05:31:23 +02:00
minor bug fixes and changed rubocop
This commit is contained in:
parent
511b7b0c02
commit
6b14f40331
4 changed files with 19 additions and 21 deletions
|
@ -80,7 +80,7 @@ Style/MultilineBlockChain:
|
||||||
# Current preferred metrics --------------------------------------------
|
# Current preferred metrics --------------------------------------------
|
||||||
# Better values are encouraged, but not required.
|
# Better values are encouraged, but not required.
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Max: 20
|
Max: 30
|
||||||
|
|
||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
Max: 20
|
Max: 20
|
||||||
|
@ -88,6 +88,9 @@ Metrics/MethodLength:
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
Max: 7
|
Max: 7
|
||||||
|
|
||||||
|
Metrics/PerceivedComplexity:
|
||||||
|
Max: 8
|
||||||
|
|
||||||
# TODO -----------------------------------------------------------------
|
# TODO -----------------------------------------------------------------
|
||||||
|
|
||||||
Style/Documentation:
|
Style/Documentation:
|
||||||
|
|
|
@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
|
||||||
spec.add_runtime_dependency 'facets'
|
spec.add_runtime_dependency 'facets'
|
||||||
spec.add_runtime_dependency 'ruby-terminfo'
|
spec.add_runtime_dependency 'ruby-terminfo'
|
||||||
spec.add_runtime_dependency 'filesize'
|
spec.add_runtime_dependency 'filesize'
|
||||||
|
spec.add_runtime_dependency 'git'
|
||||||
|
|
||||||
spec.add_development_dependency 'bundler', '~> 1.15'
|
spec.add_development_dependency 'bundler', '~> 1.15'
|
||||||
spec.add_development_dependency 'rake'
|
spec.add_development_dependency 'rake'
|
||||||
|
|
|
@ -4,6 +4,7 @@ require 'facets'
|
||||||
require 'terminfo'
|
require 'terminfo'
|
||||||
require 'etc'
|
require 'etc'
|
||||||
require 'filesize'
|
require 'filesize'
|
||||||
|
require 'git'
|
||||||
|
|
||||||
require 'colorls/core'
|
require 'colorls/core'
|
||||||
require 'colorls/flags'
|
require 'colorls/flags'
|
||||||
|
|
|
@ -219,33 +219,25 @@ module ColorLS
|
||||||
end
|
end
|
||||||
|
|
||||||
def git_info(path,content)
|
def git_info(path,content)
|
||||||
require 'git'
|
until File.exist?('.git') # check whether the repository is git controlled
|
||||||
while(!File.exist?(".git")) #check whether the repository is git controlled
|
return '' if Dir.pwd=='/'
|
||||||
if(Dir.pwd=="/")
|
Dir.chdir('..')
|
||||||
return ""
|
|
||||||
end
|
|
||||||
Dir.chdir("..")
|
|
||||||
end
|
end
|
||||||
instance = Git.open '.'
|
instance = Git.open '.'
|
||||||
a = instance.status.added.keys # Added files
|
a = instance.status.added.keys # Added files
|
||||||
u = instance.status.untracked.keys # Untracked files
|
u = instance.status.untracked.keys # Untracked files
|
||||||
c = instance.status.changed.keys # Changed files
|
c = instance.status.changed.keys # Changed files
|
||||||
p = path
|
p = path
|
||||||
p.slice! Dir.pwd+"/"
|
p.slice! Dir.pwd+'/'
|
||||||
if(p==path)
|
if p==path
|
||||||
p=""
|
p=''
|
||||||
else
|
else
|
||||||
p=p+"/"
|
p+='/'
|
||||||
end
|
|
||||||
if a.any? {|x| x.include? "#{p}#{content}"}
|
|
||||||
return 'A'
|
|
||||||
elsif u.any? {|x| x.include? "#{p}#{content}"}
|
|
||||||
return 'U'
|
|
||||||
elsif c.any? {|x| x.include? "#{p}#{content}"}
|
|
||||||
return 'C'
|
|
||||||
else
|
|
||||||
return '-'
|
|
||||||
end
|
end
|
||||||
|
return 'A' if a.any? { |x| x.include? "#{p}#{content}" }
|
||||||
|
return 'U' if u.any? { |x| x.include? "#{p}#{content}" }
|
||||||
|
return 'C' if c.any? { |x| x.include? "#{p}#{content}" }
|
||||||
|
p = '-'
|
||||||
end
|
end
|
||||||
|
|
||||||
def long_info(path, content)
|
def long_info(path, content)
|
||||||
|
@ -254,7 +246,8 @@ module ColorLS
|
||||||
return '[No Info]'.colorize(@colors[:error]) + ' ' * (39 + @userlength + @grouplength)
|
return '[No Info]'.colorize(@colors[:error]) + ' ' * (39 + @userlength + @grouplength)
|
||||||
end
|
end
|
||||||
stat = File.stat("#{path}/#{content}")
|
stat = File.stat("#{path}/#{content}")
|
||||||
[mode_info(stat), user_info(stat), group_info(stat), size_info(stat), mtime_info(stat),git_info(path,content)].join(' ')
|
[mode_info(stat), user_info(stat), group_info(stat), size_info(stat), mtime_info(stat),
|
||||||
|
git_info(path,content)].join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
def symlink_info(path, content)
|
def symlink_info(path, content)
|
||||||
|
|
Loading…
Reference in a new issue