Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jtmitchell/bf48267471531e2e3e7b to your computer and use it in GitHub Desktop.

Select an option

Save jtmitchell/bf48267471531e2e3e7b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Generates gource video out of multiple repositories.
# First, get a local branch/clone of each repository.
# Then, pass the repositories as command line arguments.
#
# Example:
# $ gource-multiple-repositories.sh /path/to/repo1 /path/to/repo2
OUTFILE="gource"
GITBRANCH="master"
TIMESCALE="2.0"
SIZE="1280x720"
FRAMERATE="25"
TITLE=""
HIDE="mouse,progress,filenames"
while getopts ":ho:b:t:s:" opt
do
case "$opt" in
o) OUTFILE="$OPTARG";;
b) GITBRANCH="$OPTARG";;
t) TIMESCALE="$OPTARG";;
s) SIZE="$OPTARG";;
t) TITLE="$OPTARG";;
h|*) # Usage message
echo "
usage: $0 [options] repo1 repo2 repo3
-o FILE-BASE name for output without the .mp4 [${OUTFILE}]
-b BRANCH a common branch to display [${GITBRANCH}]
-t SCALE time scale to use 0-4.0 [${TIMESCALE}]
-s SIZE video size [${SIZE}]
-t NAME video title [${TITLE}]
"
exit
;;
esac
done
shift $(($OPTIND-1))
REPO_TITLES=""
combined_log="$(mktemp /tmp/gource_combined.XXXXXX)"
for repo in $*; do
if [ -z "${REPO_TITLES}" ]; then
REPO_TITLES=$repo
else
REPO_TITLES="$REPO_TITLES, $repo"
fi
# output the repo to a logfile
logfile="$(mktemp /tmp/gource.XXXXXX)"
gource --git-branch ${GITBRANCH} --output-custom-log "${logfile}" ${repo}
# namespace the repos
sed -E 's/(.+)\|/\1\|\/'${repo}'/' ${logfile} >> $combined_log
# delete temp logfile
rm ${logfile}
done
[ -z "$TITLE" ] && TITLE="$REPO_TITLES"
# sort the combined_log
sort -n -o $combined_log $combined_log
echo "Committers:"
cat $combined_log | awk -F\| {'print $2'} | sort | uniq
echo "======================"
time gource $combined_log \
--time-scale ${TIMESCALE} \
--title "${TITLE}" \
-${SIZE} \
--auto-skip-seconds 1 \
--seconds-per-day 2 \
--multi-sampling \
--dir-colour 888888 \
--highlight-users \
--highlight-dirs \
--file-idle-time 0 \
--max-files 0 \
--hide ${HIDE} \
--stop-at-end \
--output-ppm-stream - \
--output-framerate ${FRAMERATE} \
| ffmpeg -y -r ${FRAMERATE} \
-f image2pipe -vcodec ppm -i - -vcodec libx264 \
-preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 \
${OUTFILE}.mp4
rm $combined_log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment