get_revision.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. # List of files which should be considered imprtant
  3. # for the behavior of fpcmake binary
  4. # fpcmake.inc and Makefile should be excluded from that list
  5. if [ "$#" -ge 1 ] ; then
  6. important_files="$*"
  7. else
  8. important_sources=`ls -1 fpcm*.pp fpcmake.ini Makefile.fpc`
  9. fi
  10. LANG=C
  11. export LANG
  12. tmpfiles=
  13. # git repository?
  14. if [ -d ../../.git ] ; then
  15. USEGIT=1
  16. echo Using git repository
  17. # we just look for the last commit date here
  18. for f in $important_sources ; do
  19. tmpfile=.tmp.$f
  20. tmpfiles="$tmpfiles $tmpfile"
  21. echo "Change information for $f: "
  22. git log -1 --pretty="format:%ci %h" $f > $tmpfile
  23. echo >> $tmpfile
  24. cat $tmpfile
  25. done
  26. git_date=`cat $tmpfiles | sort -n | tail -1 | gawk '{ print $1 }'`
  27. git_hash=`cat $tmpfiles | sort -n | tail -1 | gawk '{ print $4 }'`
  28. echo "Last date is $git_date, hash is $git_hash"
  29. echo "'$git_date hash $git_hash'" > revision.inc
  30. else
  31. for f in $important_sources ; do
  32. tmpfile=.tmp.$f
  33. tmpfiles="$tmpfiles $tmpfile"
  34. svn info $f > $tmpfile
  35. done
  36. # echo "svn_info is $svn_info"
  37. svn_date=`gawk '/Last Changed Date: / {print $4 }' $tmpfiles | sort -n | tail -1`
  38. svn_rev=`gawk '/Last Changed Rev: / {print $4 }' $tmpfiles | sort -n | tail -1`
  39. echo "for files $important_sources, date is $svn_date, rev is $svn_rev"
  40. echo "'$svn_date rev $svn_rev'" > revision.inc
  41. fi
  42. rm -Rf $tmpfiles