Skip to content

Instantly share code, notes, and snippets.

@mkaschenko
Last active February 11, 2021 16:43
Show Gist options
  • Save mkaschenko/1908c03be1c1e08abe0e76343aedbb7a to your computer and use it in GitHub Desktop.
Save mkaschenko/1908c03be1c1e08abe0e76343aedbb7a to your computer and use it in GitHub Desktop.
Provides churn statistics (frequency of change) for git repositories
#!/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