git-ahead-check/src/git-ahead-check.cr

19 lines
451 B
Crystal
Raw Normal View History

2022-08-11 01:37:24 +03:00
require "colorize"
repos_dirs = [""]
def check_repo(repo_path : String)
repo_name = repo_path.split("/")[-1]
2022-08-13 11:39:51 +03:00
ahead_count = `git -C #{repo_path} status | grep -i "Your branch" | grep -Eo "[0-9]"`.chomp
2022-08-11 01:37:24 +03:00
if !ahead_count.empty?
2022-08-13 11:39:51 +03:00
print "* #{ahead_count}\t".colorize(:red).mode(:bold)
2022-08-11 01:37:24 +03:00
print repo_name.colorize(:yellow)
2022-08-13 11:39:51 +03:00
print " ["
print repo_path.colorize(:light_magenta)
puts "]"
2022-08-11 01:37:24 +03:00
end
end
repos_dirs.each { |x| check_repo(x) }