1
0

get_source_date_epoch.sh 500 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env bash
  2. export LANG=C
  3. export LC_ALL=C
  4. [ -n "$TOPDIR" ] && cd $TOPDIR
  5. try_version() {
  6. [ -f version.date ] || return 1
  7. SOURCE_DATE_EPOCH="$(cat version.date)"
  8. [ -n "$SOURCE_DATE_EPOCH" ]
  9. }
  10. try_git() {
  11. [ -e .git ] || return 1
  12. SOURCE_DATE_EPOCH="$(git log -1 --format=format:%ct)"
  13. [ -n "$SOURCE_DATE_EPOCH" ]
  14. }
  15. try_hg() {
  16. [ -d .hg ] || return 1
  17. SOURCE_DATE_EPOCH=""
  18. [ -n "$SOURCE_DATE_EPOCH" ]
  19. }
  20. try_version || try_git || try_hg || SOURCE_DATE_EPOCH=""
  21. echo "$SOURCE_DATE_EPOCH"