Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ If you wrote one of these scripts and want it removed from this collection, plea
| `git-attic` | Leah Neukirchen's [blog](https://leahneukirchen.org/blog/archive/2013/01/a-grab-bag-of-git-tricks.html) | Displays a list of deleted files in your repo. The output is designed to be copy and pasted: Pass the second field to `git show` to display the file contents, or just select the hash without ^ to see the commit where removal happened. |
| `git-authors` | Michael Markert's [dotfiles](https://github.com/cofi/dotfiles) (as `git-changes`) | List authors in the repo in descending commit-count order. |
| `git-big-file` | Mislav Marohnić's [dotfiles](https://github.com/mislav/dotfiles) | Show files in the repo larger than a threshold size. |
| `git-branches-that-touch` | Mislav Marohnić's [dotfiles](https://github.com/mislav/dotfiles) | Shows which branches touch files under a path that are remote, unmerged, have a commit in the last six months and whose name doesn't start with 'enterprise-' |
| `git-branch-name` | Joe Block <jpb@unixorn.net> | Prints the current branch name in automation-friendly format. |
| `git-branch-rebaser` | Vengada Rangaraju <krangaraju@castlighthealth.com> | Kicks off an interactive rebase of all the commits on your branch. _Including pushed commits_, so be careful. |
| `git-change-author` | Michael Demmer in [jut-io/git-scripts](https://github.com/jut-io/git-scripts/blob/master/bin/git-change-author) | Change one author/email in the history to another. |
Expand Down
30 changes: 30 additions & 0 deletions bin/git-branches-that-touch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
#
# Original source: https://github.com/mislav/dotfiles/blob/master/bin/git-branches-that-touch
#
# Usage: git branches-that-touch <path>
#
# Searches:
# - branches that touch files under `<path>`,
# - that are remote and unmerged,
# - whose latest commit falls within the past 6 months,
# - whose name doesn't start with "enterprise-".
set -e

age_treshold="$(date -v-6m +%s)"
base="origin/master"

trap 'echo processing $branch >&2' INFO

for branch in $(git branch -r --no-merged "$base"); do
name="${branch#*/}"
[[ $name != enterprise-* ]] || continue

touched="$(git log -1 --format=%cd --date=raw "$branch" | awk '{print $1}')"
[ "$touched" -gt "$age_treshold" ] || continue

if git diff "${base}...${branch}" --name-only | grep -q "$1"; then
echo -n "${branch} by "
git log "${base}..${branch}" --first-parent --format=%an | sort | uniq -c | sort -rn | head -1
fi
done