2015-09-27 10:24:51 +08:00
|
|
|
#/bin/sh
|
|
|
|
#
|
|
|
|
# This script defines some helper functions used by other scripts in the docs
|
|
|
|
# folder.
|
|
|
|
|
|
|
|
|
2019-03-04 00:10:07 +08:00
|
|
|
# Get the time the given filename was last modified.
|
2015-09-27 10:24:51 +08:00
|
|
|
get_last_modified_date()
|
|
|
|
{
|
2019-03-04 00:10:07 +08:00
|
|
|
local filename=$1
|
|
|
|
RESULT=`git log -1 --format="%ad" --date=format:'%b %d, %Y' -- $filename`
|
2015-09-27 10:24:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
get_dlib_version()
|
|
|
|
{
|
|
|
|
cat ../dlib/CMakeLists.txt | awk '/set\(CPACK_PACKAGE_VERSION_'$1'/{ match($2,"\"(.*)\"",a); print a[1]}'
|
|
|
|
}
|
|
|
|
|
2019-03-04 00:10:07 +08:00
|
|
|
# Dump a copy of the repo contents to $1
|
|
|
|
dump_repo_to()
|
|
|
|
{
|
|
|
|
mkdir -p $1
|
|
|
|
git archive HEAD `git rev-parse --show-toplevel` | tar -xC $1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Call like git_logs_as_xml HEAD~4..HEAD out.xml to write the logs in that range to out.xml
|
|
|
|
git_logs_as_xml()
|
|
|
|
{
|
|
|
|
local logrange=$1
|
|
|
|
local outfile=$2
|
|
|
|
|
|
|
|
# What paths to include in the logs
|
|
|
|
local paths="../dlib ../examples ../tools ../python_examples"
|
|
|
|
|
2020-06-07 02:26:27 +08:00
|
|
|
(echo "<log>"; git log --stat=80 --date=iso-strict --pretty=format:"</files_changed></logentry>%n<logentry revision=\"%H\">%n<author email=\"%ae\">%an</author>%n<date>%ad</date>%nGIT_COMMIT_MESSAGE_BEGIN%sGIT_COMMIT_MESSAGE_END%n<files_changed>%n" $logrange $paths | tail -n+2 ; echo; echo '</files_changed></logentry>' ; echo "</log>" ) > $outfile
|
|
|
|
|
|
|
|
# sanitize git commit messages
|
|
|
|
sed -e '/GIT_COMMIT_MESSAGE_BEGIN.*GIT_COMMIT_MESSAGE_END/ { s/</\</g; s/>/\>/g; s/GIT_COMMIT_MESSAGE_BEGIN/<msg>/g; s/GIT_COMMIT_MESSAGE_END/<\/msg>/g; }' -i $outfile
|
2019-03-04 00:10:07 +08:00
|
|
|
|
|
|
|
# trim whitespace at start and end of <files_changed> tags.
|
|
|
|
sed -e ':a' -e 'N' -e '$!ba' -e "s/<files_changed>[ \n]*/<files_changed> /g" -e "s/[ \n]*<\/files_changed>/<\/files_changed>/g" -i $outfile
|
|
|
|
}
|
2015-09-27 10:24:51 +08:00
|
|
|
|
2019-03-04 00:10:07 +08:00
|
|
|
# call like: set_dlib_version MAJOR 42 to set MAJOR version to 42.
|
2015-09-27 10:24:51 +08:00
|
|
|
set_dlib_version()
|
|
|
|
{
|
|
|
|
sed -i -e 's/\(set(CPACK_PACKAGE_VERSION_'$1' *"\).*\(".*\)/\1'$2'\2/' ../dlib/CMakeLists.txt
|
|
|
|
}
|
|
|
|
|
|
|
|
MAJOR_NUM=`get_dlib_version MAJOR`
|
|
|
|
MINOR_NUM=`get_dlib_version MINOR`
|
|
|
|
PATCH_NUM=`get_dlib_version PATCH`
|