Compare commits
7 Commits
c8d0aa91e9
...
c2ec42e289
Author | SHA1 | Date |
---|---|---|
Alexander Popov | c2ec42e289 | |
Alexander Popov | b9e61ef101 | |
Alexander Popov | 5add145cef | |
Alexander Popov | a535f4eb03 | |
Alexander Popov | f1fef21f83 | |
Alexander Popov | 0da77e69e5 | |
Alexander Popov | 1eca440f02 |
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
|
@ -0,0 +1,40 @@
|
|||
Git Ahead Check
|
||||
===============
|
||||
|
||||
Инструмент для людей, которые много работают
|
||||
|
||||
![img](./.docs/screenshot.png)
|
||||
|
||||
## Installing
|
||||
**Using prebuilder binary:**
|
||||
|
||||
...
|
||||
|
||||
**Build from source:**
|
||||
|
||||
Download sources by Git:
|
||||
|
||||
```sh
|
||||
git clone http://git.a2s.su/iiiypuk/git-ahead-check.git .
|
||||
```
|
||||
|
||||
(Or) Download source by Zip:
|
||||
|
||||
```sh
|
||||
wget https://git.a2s.su/iiiypuk/git-ahead-check/archive/master.zip || uznip ./master.zip
|
||||
```
|
||||
|
||||
Build:
|
||||
|
||||
```sh
|
||||
cd ./git-ahead-check/
|
||||
shards build
|
||||
|
||||
./bin/git-ahead-check # enjoy
|
||||
```
|
||||
|
||||
## Howto use
|
||||
**Generate configuration file:**
|
||||
```sh
|
||||
$ ls -d -1 ~/Develop/* > ~/.config/emilecok/git-ahead-check
|
||||
```
|
|
@ -1,16 +1,69 @@
|
|||
require "colorize"
|
||||
require "option_parser"
|
||||
|
||||
repos_dirs = [""]
|
||||
VERSION = {{ `shards version "#{__DIR__}"`.chomp.stringify }}
|
||||
short_output = false
|
||||
|
||||
def check_repo(repo_path : String)
|
||||
repo_name = repo_path.split("/")[-1]
|
||||
ahead_count = `git -C #{repo_path} status | grep -i "Your branch" | grep -Eo "[0-9]"`
|
||||
begin
|
||||
OptionParser.parse do |parser|
|
||||
parser.banner = "The very simple password manager for humans\n"
|
||||
|
||||
if !ahead_count.empty?
|
||||
print repo_name.colorize(:yellow)
|
||||
print " " * (25 - repo_name.size)
|
||||
print ahead_count.to_s.colorize(:green).mode(:bold)
|
||||
parser.on "-h", "--help", "Show help" do
|
||||
puts parser
|
||||
exit(0)
|
||||
end
|
||||
|
||||
parser.on "-s", "Short output" do
|
||||
short_output = true
|
||||
end
|
||||
|
||||
parser.on "-v", "Show version" do
|
||||
puts VERSION
|
||||
exit(0)
|
||||
end
|
||||
end
|
||||
rescue ex
|
||||
puts ex.message, ""
|
||||
end
|
||||
|
||||
repos_dirs.each { |x| check_repo(x) }
|
||||
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, short_output) }
|
||||
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, show_path)
|
||||
if !Dir.exists?(repo_path.sub("$HOME", ENV["HOME"]))
|
||||
return 0
|
||||
end
|
||||
|
||||
if !Dir.exists?("#{repo_path}/.git")
|
||||
return 0
|
||||
end
|
||||
|
||||
repo_name = repo_path.split("/")[-1]
|
||||
ahead_count = `git -C #{repo_path} status | grep -i "Your branch" | grep -Eo "[0-9]"`.chomp
|
||||
|
||||
if !ahead_count.empty?
|
||||
print "* #{ahead_count}\t".colorize(:red).mode(:bold)
|
||||
print repo_name.colorize(:yellow)
|
||||
|
||||
if !show_path
|
||||
print " ["
|
||||
print repo_path.colorize(:light_magenta)
|
||||
puts "]"
|
||||
else
|
||||
puts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue