-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# git-heatmap | ||
|
||
> Display a heatmap for oft-edited files | ||
![screenshot of git heatmap](screenshot.png) | ||
|
||
## Install | ||
|
||
### Dependencies | ||
|
||
You must have the `bars` command on your system first: | ||
|
||
``` | ||
npm install -g https://github.com/jez/bars.git | ||
``` | ||
|
||
### Installation | ||
|
||
Download `git-heatmap` and put it on your path. | ||
|
||
```bash | ||
# Homebrew: | ||
brew install jez/formulae/git-heatmap | ||
``` | ||
|
||
## Usage | ||
|
||
``` | ||
❯ git heatmap -h | ||
Heatmap of oft-edited files. | ||
Usage: | ||
git heatmap [options] [<path>...] | ||
Options: | ||
-n <top> Limit to top <n> files. [default: 30] | ||
--width <n> Limit histogram to <n> chars. | ||
-b <branch>, --base <branch> Compare relative to <branch>. If on <branch>, | ||
show heatmap for entire repo. [default: master] | ||
-h Show this message. | ||
``` | ||
|
||
## License | ||
|
||
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://jez.io/MIT-LICENSE.txt) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Build a commit frequency histogram | ||
|
||
ccyan="$(echo -ne '\033[0;36m')" | ||
cnone="$(echo -ne '\033[0m')" | ||
|
||
argv=() | ||
while [[ $# -gt 0 ]]; do | ||
key="$1" | ||
case $key in | ||
-n) | ||
LIMIT="$2" | ||
shift | ||
shift | ||
;; | ||
-b|--base) | ||
REVIEW_BASE="$2" | ||
shift | ||
shift | ||
;; | ||
-h) | ||
cat <<EOF | ||
Heatmap of oft-edited files. | ||
Usage: | ||
git heatmap [options] [<path>...] | ||
Options: | ||
-n <top> Limit to top <n> files. [default: 30] | ||
-b <branch>, --base <branch> Compare relative to <branch>. If on <branch>, | ||
show heatmap for entire repo. [default: master] | ||
-h Show this message. | ||
EOF | ||
exit | ||
;; | ||
*) | ||
argv+=("$1") | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
LIMIT=${LIMIT:-30} | ||
REVIEW_BASE=${REVIEW_BASE:-master} | ||
|
||
files() { | ||
git log --name-status --pretty=format: -- "${argv[@]}" | cut -f 2- | ||
} | ||
|
||
color_name() { | ||
# \(.*\/\)\([^/ ]*\) | ||
sed -e "s/\(..*\/\)*\(.[^|]*\) |/\1$ccyan\2$cnone |/" | ||
} | ||
|
||
filter() { | ||
sort | \ | ||
uniq -c | \ | ||
sort -nr | \ | ||
tail -n +2 | \ | ||
head -n "$LIMIT" | ||
} | ||
|
||
if [[ "$(git branch | grep '\*')" =~ $REVIEW_BASE ]]; then | ||
# If on master, show heatmap for whole repo | ||
files | filter | bars --bar █ | color_name | ||
else | ||
MERGE_BASE="$(git merge-base HEAD "$REVIEW_BASE")" | ||
files | \ | ||
# If on separate branch, show heatmap for files changed since master | ||
grep -xF -f <(git diff --name-only "$MERGE_BASE") | \ | ||
filter | \ | ||
bars --bar █ | \ | ||
color_name | ||
fi | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.