From c8d0aa91e972246ab88ae97dbd598fc527035ddf Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Thu, 11 Aug 2022 01:37:24 +0300 Subject: [PATCH] init --- .editorconfig | 15 +++++++++++++++ shard.yml | 24 ++++++++++++++++++++++++ src/git-ahead-check.cr | 16 ++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 .editorconfig create mode 100644 shard.yml create mode 100644 src/git-ahead-check.cr diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..30ea6c6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +# for all projects +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +# Crystal +[*.cr] +indent_style = space +indent_size = 2 diff --git a/shard.yml b/shard.yml new file mode 100644 index 0000000..9fa23f7 --- /dev/null +++ b/shard.yml @@ -0,0 +1,24 @@ +name: git-ahead-check +version: 0.1.0 + +# authors: +# - name + +# description: | +# Short description of git-ahead-check + +# dependencies: +# pg: +# github: will/crystal-pg +# version: "~> 0.5" + +# development_dependencies: +# webmock: +# github: manastech/webmock.cr + +# license: MIT + +targets: + git-ahead-check: + main: src/git-ahead-check.cr + diff --git a/src/git-ahead-check.cr b/src/git-ahead-check.cr new file mode 100644 index 0000000..587df5c --- /dev/null +++ b/src/git-ahead-check.cr @@ -0,0 +1,16 @@ +require "colorize" + +repos_dirs = [""] + +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]"` + + if !ahead_count.empty? + print repo_name.colorize(:yellow) + print " " * (25 - repo_name.size) + print ahead_count.to_s.colorize(:green).mode(:bold) + end +end + +repos_dirs.each { |x| check_repo(x) }