Last active
February 11, 2021 16:43
-
-
Save mkaschenko/1908c03be1c1e08abe0e76343aedbb7a to your computer and use it in GitHub Desktop.
Provides churn statistics (frequency of change) for git repositories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
# This program modifies the original output of git-churn program https://github.com/garybernhardt/dotfiles/blob/master/bin/git-churn. | |
# It highlights current project files in green colour. | |
unless Kernel.system('command -v git-churn &> /dev/null') | |
STDOUT.puts("Install git-churn first. See details at https://github.com/garybernhardt/dotfiles/blob/master/bin/git-churn") | |
Kernel.exit | |
end | |
green = ->(text) { "\033[32m#{text}\033[0m" } | |
output = `git churn` | |
project_files = Dir['**/*', '.*'] | |
output.each_line do |line| | |
file = line.split.last | |
if project_files.include?(file) | |
line = green.call(line) | |
end | |
STDOUT.print(line) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment