Skip to content

Instantly share code, notes, and snippets.

@nickanderson
Last active July 9, 2023 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickanderson/48fc8e3381f288bcf5b37e6f0aa94c1a to your computer and use it in GitHub Desktop.
Save nickanderson/48fc8e3381f288bcf5b37e6f0aa94c1a to your computer and use it in GitHub Desktop.
How I generated a gource visualization of some org-files stored in git repositories

I have a long history of using org-mode, but I don’t have a consistent history of tracking it under version control. I have at times and then stopped, I don’t push my git repository anywhere, it does get backed up periodically. Some of my org-mode files get copied around to multiple devices (typically bi-directional sync, but you can get creative with send only and exclusions etc ..). Anyway, I have a few different git repositories that contain org-mode files and I wanted to visualize activity over time. Gource produces a nifty visualization, and you can even interact with it, zooming in, panning around while being able to see user, directory, and file names.

I use this city script to generate videos like https://www.youtube.com/watch?v=b7y0y6sWb2I

#!/bin/bash
set -e
set -u
set -x

# brew/apt/yum/flake whatever install gource ffmpeg

# repos="<repo1> <repo2> ... <repoN>"
repopaths="/home/nickanderson/org"

TMPDIR=$(mktemp -d)
cd "${TMPDIR}"
rm -rf repos logs out
mkdir -p repos logs out
for REPOPATH in $repopaths
do
    REPO=$(basename $REPOPATH)
    cd repos
    git clone "${REPOPATH}" "${REPO}"
    gource --output-custom-log "${TMPDIR}/logs/${REPO}.log" "${REPO}"
    awk -F\| -v repo="$REPO" '{print $1 "|" $2 "|" $3 "|" repo $4}' "${TMPDIR}/logs/${REPO}.log" > "${TMPDIR}/logs/${REPO}.gourced.log"
    cd ../
done
cd logs
cat ./*.gourced.log | sort -n > combined.gourced.log
gource combined.gourced.log \
       --highlight-users \
       --highlight-dirs \
       -1280x720 \
       --seconds-per-day 0.125 \
       --max-files 0 \
       --title "Nick's Org-mode" \
       --hide directories,filenames,usernames,bloom \
       --dir-name-depth 3\
       -o ${TMPDIR}/out/gource-multi-repos.ppm
ffmpeg -y \
       -r 60 \
       -f image2pipe \
       -vcodec ppm \
       -i ${TMPDIR}/out/gource-multi-repos.ppm \
       -vcodec libx264 \
       -preset ultrafast \
       -pix_fmt yuv420p \
       -crf 1 \
       -threads 0 \
       -bf 0 \
       ${TMPDIR}/out/gource-multi-repos.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment