2020-04-28 21:17:02 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-05-12 13:50:01 +00:00
|
|
|
# This can be easily used with something like:
|
|
|
|
# for B in $(list_old_branches.sh); do git branch --delete "${BRANCH}"; done
|
|
|
|
|
2020-04-28 21:17:02 +00:00
|
|
|
function getCommitUnix() {
|
|
|
|
git show --no-patch --no-notes --pretty='%at' ${1}
|
|
|
|
}
|
|
|
|
|
2020-06-30 07:29:34 +00:00
|
|
|
OLDER_THAN_DAYS="90"
|
2020-04-28 21:17:02 +00:00
|
|
|
CURRENT_TIME=$(date +%s)
|
|
|
|
OLDER_THAN_UNIX=$(( ${OLDER_THAN_DAYS} * 86400 ))
|
|
|
|
OLDER_THAN=$(( ${CURRENT_TIME} - ${OLDER_THAN_UNIX} ))
|
|
|
|
|
|
|
|
REMOTE="origin"
|
|
|
|
REMOTE_BRANCHES=$(git ls-remote --heads --heads ${REMOTE} | cut -f2)
|
|
|
|
|
|
|
|
for BRANCH in ${REMOTE_BRANCHES}; do
|
|
|
|
BRANCH_NAME="${BRANCH/#refs\/heads\/}"
|
2020-05-12 13:50:01 +00:00
|
|
|
if [[ ${BRANCH_NAME} = release* ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
2020-04-28 21:17:02 +00:00
|
|
|
COMMIT_DATE_UNIX=$(getCommitUnix remotes/origin/$BRANCH_NAME)
|
|
|
|
if [[ ${COMMIT_DATE_UNIX} < ${OLDER_THAN} ]]; then
|
|
|
|
echo "${BRANCH_NAME}"
|
|
|
|
fi
|
|
|
|
done
|