mirror of
https://github.com/donovanglover/nix-config.git
synced 2025-06-20 17:57:47 +02:00
Add working file comparison implementation to maid.cr
This commit is contained in:
parent
d553d267c3
commit
9aa5eddf71
17
src/maid.cr
17
src/maid.cr
@ -97,7 +97,22 @@ module Maid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def status()
|
def status()
|
||||||
puts "Status"
|
# For each file in upstream
|
||||||
|
Dir.glob(ENV["HOME"] + Maid::UPSTREAM + "/**/*").each do |upstream|
|
||||||
|
next if File.directory?(upstream)
|
||||||
|
downstream = upstream.sub(UPSTREAM, "")
|
||||||
|
puts Trucolor.format({180, 0, 255}, upstream.sub(ENV["HOME"], "~")) + " -> " + Trucolor.format({255, 0, 128}, downstream.sub(ENV["HOME"], "~"))
|
||||||
|
# If the file upstream exists downstream
|
||||||
|
if File.exists?(downstream)
|
||||||
|
# Print a summary of what's different if they aren't the same
|
||||||
|
unless upstream.includes?(".jpg") || FileUtils.cmp(upstream, downstream)
|
||||||
|
puts "Lines in the upstream repository but not stored locally:"
|
||||||
|
puts Trucolor.format({20, 200, 255}, `grep -nFxvf #{upstream} #{downstream}`)
|
||||||
|
puts "Lines stored locally but not upstream:"
|
||||||
|
puts Trucolor.format({255, 200, 58}, `grep -nFxvf #{downstream} #{upstream}`)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user