Skip to content

Instantly share code, notes, and snippets.

@RatoX
Created September 25, 2019 03:27
Show Gist options
  • Save RatoX/fa8ff421d8ff8813fa8a06b37255f8e0 to your computer and use it in GitHub Desktop.
Save RatoX/fa8ff421d8ff8813fa8a06b37255f8e0 to your computer and use it in GitHub Desktop.
List last worked branchs
#!/usr/local/bin/bash
# OS x only
function last_branchs {
readarray array <<< $(git for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)')
FIVE_DAYS_AGO=$(date -v-5d "+%s")
for row in "${array[@]}";do
row_array=(${row})
date_str=${row_array[0]}
date_unix=$(date -j -f "%Y-%m-%d" $date_str "+%s")
if [ "$date_unix" -gt "$FIVE_DAYS_AGO" ]
then
echo ${row_array[@]}
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment