Compare commits

...

7 Commits

Author SHA1 Message Date
Alexander Popov c2ec42e289
guide for build from source 2022-08-13 16:26:30 +03:00
Alexander Popov b9e61ef101
add short output 2022-08-13 16:23:03 +03:00
Alexander Popov 5add145cef
add options 2022-08-13 16:16:01 +03:00
Alexander Popov a535f4eb03
add screenshot 2022-08-13 12:41:39 +03:00
Alexander Popov f1fef21f83
check ".git" dir 2022-08-13 12:37:44 +03:00
Alexander Popov 0da77e69e5
config file 2022-08-13 12:24:27 +03:00
Alexander Popov 1eca440f02
make beaty output 2022-08-13 11:39:51 +03:00
3 changed files with 102 additions and 9 deletions

BIN
.docs/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

40
README.md Normal file
View File

@ -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
```

View File

@ -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