config file
This commit is contained in:
parent
1eca440f02
commit
0da77e69e5
|
@ -1,8 +1,26 @@
|
||||||
require "colorize"
|
require "colorize"
|
||||||
|
|
||||||
repos_dirs = [""]
|
CONFIG_PATH = "#{ENV["HOME"]}/.config/emilecok/git-ahead-check"
|
||||||
|
|
||||||
|
if File.exists?(CONFIG_PATH)
|
||||||
|
a = File.read_lines(CONFIG_PATH)
|
||||||
|
|
||||||
|
repos_dirs = File.read_lines(CONFIG_PATH)
|
||||||
|
|
||||||
|
repos_dirs.each { |x| check_repo(x) }
|
||||||
|
else
|
||||||
|
Dir.mkdir_p(File.dirname(CONFIG_PATH))
|
||||||
|
File.new(CONFIG_PATH, "w")
|
||||||
|
|
||||||
|
print File.dirname(CONFIG_PATH)
|
||||||
|
puts " directory created.\n"
|
||||||
|
end
|
||||||
|
|
||||||
def check_repo(repo_path : String)
|
def check_repo(repo_path : String)
|
||||||
|
if !Dir.exists?(repo_path.sub("$HOME", ENV["HOME"]))
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
repo_name = repo_path.split("/")[-1]
|
repo_name = repo_path.split("/")[-1]
|
||||||
ahead_count = `git -C #{repo_path} status | grep -i "Your branch" | grep -Eo "[0-9]"`.chomp
|
ahead_count = `git -C #{repo_path} status | grep -i "Your branch" | grep -Eo "[0-9]"`.chomp
|
||||||
|
|
||||||
|
@ -14,5 +32,3 @@ def check_repo(repo_path : String)
|
||||||
puts "]"
|
puts "]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
repos_dirs.each { |x| check_repo(x) }
|
|
||||||
|
|
Loading…
Reference in New Issue