Skip to content

Commit

Permalink
Add smudge and clean filters to automatically set edit date.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCallow committed Mar 14, 2016
1 parent b7d1115 commit c966dbc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Date keyword expansion
specs/latest/**/index.html filter=dater
9 changes: 9 additions & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Filters used by WebGL repo
[filter "dater"]
smudge = bash expand_date %f
clean = bash -c \"sed -e 's/\\(<span id=\\\"LastEditDate\\\">\\).*\\(<\\/span>\\)/\\1\\2/'\"
required

# Needed to avoid merge conflicts
[merge]
renormalize = true
10 changes: 10 additions & 0 deletions .gitconfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

# Set colors
GREEN='\033[1;32m'
NC='\033[0m'

# Connect repo's .gitconfig
git config --local include.path '../.gitconfig'
printf "${GREEN}Git config was successfully set.${NC}\n"

10 changes: 10 additions & 0 deletions expand_date
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/bash

# Smudge driver for the kwexpander filter for expanding keywords. Currently
# only $Date$ is supported.
#
# See CONTRIBUTING.md for usage information.

last_date=$(git log --pretty=format:"%ad" -1 HEAD -- "$1")
sed -e 's/\(<span id=\"LastEditDate\">\).*\(<\/span>\)/\1'"$last_date"'\2/'

0 comments on commit c966dbc

Please sign in to comment.