Skip to content

Instantly share code, notes, and snippets.

@ktomk
Last active April 20, 2016 05:10
Show Gist options
  • Save ktomk/664d4f5e456c135fd6009e90c5a8da25 to your computer and use it in GitHub Desktop.
Save ktomk/664d4f5e456c135fd6009e90c5a8da25 to your computer and use it in GitHub Desktop.
gitbl - git branch list : review all non master / develop branches, sortable-by-time
#!/bin/bash
git_list_branches()
{
git branch | awk -F ' +' '! /^\(no branch\)|master|develop$/ {print $2}' | sort
}
git_contains_branches()
{
git branch --contains "${1}" | awk -F ' +' '! /^\(no branch\)$/ {print $2}' | sort
}
git_in_branch()
{
local commit="${1}"
local branch="${2}"
if git_contains_branches "${commit}" | grep -q "^${branch}\$"; then
echo -e "\e[01;32min ${branch}\e[0m"
else
echo -e "\e[01;31mnot in ${branch}\e[0m"
fi
return 0
}
git_list_last_commits()
{
local line=""
while IFS=$'\n' read -r branch || [ -n "${branch}" ] && [ ! -z "${branch}" ]; do
line="$(git show -s --pretty=format:"%ai %h%d" -1 "$branch") - $(git_in_branch "$branch" "develop")"
echo "${line}"
done <<< "$(git_list_branches)"
}
git_list_last_commits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment