minor bug fixes and changed rubocop

This commit is contained in:
rohitner 2017-08-26 18:31:37 +05:30
parent 511b7b0c02
commit 6b14f40331
4 changed files with 19 additions and 21 deletions

View file

@ -80,7 +80,7 @@ Style/MultilineBlockChain:
# Current preferred metrics --------------------------------------------
# Better values are encouraged, but not required.
Metrics/AbcSize:
Max: 20
Max: 30
Metrics/MethodLength:
Max: 20
@ -88,6 +88,9 @@ Metrics/MethodLength:
Metrics/CyclomaticComplexity:
Max: 7
Metrics/PerceivedComplexity:
Max: 8
# TODO -----------------------------------------------------------------
Style/Documentation:

View file

@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'facets'
spec.add_runtime_dependency 'ruby-terminfo'
spec.add_runtime_dependency 'filesize'
spec.add_runtime_dependency 'git'
spec.add_development_dependency 'bundler', '~> 1.15'
spec.add_development_dependency 'rake'

View file

@ -4,6 +4,7 @@ require 'facets'
require 'terminfo'
require 'etc'
require 'filesize'
require 'git'
require 'colorls/core'
require 'colorls/flags'

View file

@ -219,33 +219,25 @@ module ColorLS
end
def git_info(path,content)
require 'git'
while(!File.exist?(".git")) #check whether the repository is git controlled
if(Dir.pwd=="/")
return ""
end
Dir.chdir("..")
until File.exist?('.git') # check whether the repository is git controlled
return '' if Dir.pwd=='/'
Dir.chdir('..')
end
instance = Git.open '.'
a = instance.status.added.keys # Added files
u = instance.status.untracked.keys # Untracked files
c = instance.status.changed.keys # Changed files
p = path
p.slice! Dir.pwd+"/"
if(p==path)
p=""
p.slice! Dir.pwd+'/'
if p==path
p=''
else
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 '-'
p+='/'
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
def long_info(path, content)
@ -254,7 +246,8 @@ module ColorLS
return '[No Info]'.colorize(@colors[:error]) + ' ' * (39 + @userlength + @grouplength)
end
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
def symlink_info(path, content)