Skip to content

Instantly share code, notes, and snippets.

@mjhm
Last active February 5, 2017 00:03
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 mjhm/01fe5e1a3daa34bb63c93d58b2875201 to your computer and use it in GitHub Desktop.
Save mjhm/01fe5e1a3daa34bb63c93d58b2875201 to your computer and use it in GitHub Desktop.
semi automatic doc tagging for cdn.rawgit.com links
#! /bin/bash
#
# This script updates links in *.md files that look like
# https://cdn.rawgit.com/mygithub/myrepo/doctag201702041450/doc/some_doc.html
# to new timestamps and creates the corresponding git tags.
#
# Run it at root of the repo before checking in changes, and be sure to include `--tags` when you push to remotes.
#
CURTAG=`cat doc/doctag`
NEWTAG=`date '+doctag%Y%m%d%H%M'`
# skips updates in "node_modules" and "doc" folders
find . -name node_modules -prune -o -name doc -prune -o -name '*.md' -print -exec sed -i '' "s/doctag[0-9]*/$NEWTAG/g" {} \;
echo $NEWTAG > doc/doctag
git tag -d $CURTAG
git tag $NEWTAG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment