Skip to content

Instantly share code, notes, and snippets.

@yzgyyang
Created December 26, 2020 14:35
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 yzgyyang/36f0003c97958737fbd12fd96e8094be to your computer and use it in GitHub Desktop.
Save yzgyyang/36f0003c97958737fbd12fd96e8094be to your computer and use it in GitHub Desktop.
#!/bin/sh -e
DOC_TREE="/usr/home/guangyuan/fbrepo/freebsd-doc/zh_TW.UTF-8" #/zh_CN.UTF-8
echo "Doc tree defined as ${DOC_TREE}."
cd ${DOC_TREE}
FILES_CVT=$(ag --files-with-matches "Original [Rr]evision: r[0-9]*\s")
echo $(echo ${FILES_CVT} | wc -w) files
for filename in ${FILES_CVT}; do
svn_rev=$(sed -n -e 's/.*Original [Rr]evision: r\([0-9]*\).*/\1/p' ${filename})
git_hash=$(git log --grep revision=${svn_rev} | head -n1 | cut -d' ' -f2 | head -c10)
sed -i '' "s/\(.*Original \)[Rr]\(evision: \)r\([0-9]*\)\(.*\)/\1R\2${git_hash} (r\3)\4/g" ${filename}
echo ${svn_rev} ${git_hash} ${filename}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment