From d04b76c322803528e017e696ff9350c7e160dcdc Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Thu, 16 Dec 2021 10:10:45 -0800 Subject: add git watchlist --- git-watchlist | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 git-watchlist diff --git a/git-watchlist b/git-watchlist new file mode 100755 index 0000000..6cd15b5 --- /dev/null +++ b/git-watchlist @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby +# +# git watchlist - report changes in certain files only +# +# To use this, create a file `.git/watchlist' which is simply a list of files +# that you want to monitor, one file per line. Populate it with `fd' or `find' +# or `git ls-files | grep'. Then, `git watchlist ' can be used to get a +# changelog for only those files you care about. +# +# This is very useful in a post-checkout script, so you can quickly see what +# changed in the files you care about every time you pull from upstream. + +require 'optparse' + +gitdir = `git rev-parse --git-common-dir`.chomp +watchlist = File.readlines(gitdir+"/watchlist").map(&:chomp).join(' ') +opts = {} + +OptionParser.new do |opt| + opt.banner = "usage: git watchlist [--short|--stat] " + opt.on('--short') do + opts[:short] = true + end + opt.on('--stat') do + opts[:stat] = true + end +end.parse! + +if opts[:short] + puts `git shortlog --no-merges #{ARGV[0]} -- #{watchlist}` +elsif opts[:stat] + puts `git log --stat --color=always --no-merges #{ARGV[0]} -- #{watchlist}` +else + puts `git log --color=always --no-merges #{ARGV[0]} -- #{watchlist}` +end -- cgit v1.2.3