mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-19 05:31:23 +02:00
added -gs flag
This commit is contained in:
parent
a0f2079831
commit
72f3424a0d
3 changed files with 19 additions and 19 deletions
|
@ -86,7 +86,7 @@ Metrics/MethodLength:
|
||||||
Max: 20
|
Max: 20
|
||||||
|
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
Max: 7
|
Max: 8
|
||||||
|
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Max: 8
|
Max: 8
|
||||||
|
|
|
@ -26,6 +26,7 @@ script:
|
||||||
- colorls -sf
|
- colorls -sf
|
||||||
- colorls -t
|
- colorls -t
|
||||||
- colorls -h
|
- colorls -h
|
||||||
|
- colorls -gs
|
||||||
- colorls spec/fixtures/symlinks
|
- colorls spec/fixtures/symlinks
|
||||||
- colorls README.md
|
- colorls README.md
|
||||||
- colorls *
|
- colorls *
|
||||||
|
|
|
@ -219,35 +219,33 @@ module ColorLS
|
||||||
end
|
end
|
||||||
|
|
||||||
def git_info(path, content)
|
def git_info(path, content)
|
||||||
|
return '' unless @git_status
|
||||||
until File.exist?('.git') # check whether the repository is git controlled
|
until File.exist?('.git') # check whether the repository is git controlled
|
||||||
return '' if Dir.pwd=='/'
|
return '' if Dir.pwd=='/'
|
||||||
Dir.chdir('..')
|
Dir.chdir('..')
|
||||||
end
|
end
|
||||||
instance = Git.open '.'
|
|
||||||
a = instance.status.added.keys # Added files
|
relative_path = path.remove(Dir.pwd+'/')
|
||||||
u = instance.status.untracked.keys # Untracked files
|
relative_path = relative_path==path ? '' : relative_path+'/'
|
||||||
c = instance.status.changed.keys # Changed files
|
|
||||||
p = path
|
status = Git.open('.').status
|
||||||
p.remove(Dir.pwd.to_s+'/'.to_s)
|
return 'A' if status.added.keys.any? { |a| a.include?("#{relative_path}#{content}") }
|
||||||
if p==path
|
return 'U' if status.untracked.keys.any? { |u| u.include?("#{relative_path}#{content}") }
|
||||||
p=''
|
return 'C' if status.changed.keys.any? { |c| c.include?("#{relative_path}#{content}") }
|
||||||
else
|
'-'
|
||||||
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
|
end
|
||||||
|
|
||||||
def long_info(path, content)
|
def long_info(path, content)
|
||||||
return '' unless @long
|
return '' unless @long
|
||||||
|
@git_status = true
|
||||||
unless File.exist?("#{path}/#{content}")
|
unless File.exist?("#{path}/#{content}")
|
||||||
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),
|
a = [mode_info(stat), user_info(stat), group_info(stat), size_info(stat), mtime_info(stat),
|
||||||
git_info(path,content)].join(' ')
|
git_info(path,content)].join(' ')
|
||||||
|
@git_status = false
|
||||||
|
a
|
||||||
end
|
end
|
||||||
|
|
||||||
def symlink_info(path, content)
|
def symlink_info(path, content)
|
||||||
|
@ -270,6 +268,7 @@ module ColorLS
|
||||||
|
|
||||||
[
|
[
|
||||||
long_info(path, content),
|
long_info(path, content),
|
||||||
|
git_info(path,content),
|
||||||
logo.colorize(color),
|
logo.colorize(color),
|
||||||
"#{content.colorize(color)}#{slash?(path, content)}#{symlink_info(path, content)}"
|
"#{content.colorize(color)}#{slash?(path, content)}#{symlink_info(path, content)}"
|
||||||
].join(' ')
|
].join(' ')
|
||||||
|
|
Loading…
Reference in a new issue