get_git.sh 768 B

1234567891011121314151617181920212223242526
  1. # Copyright 2025 BackendServerTemplate Authors. All rights reserved.
  2. # Use of this source code is governed by a MIT-style
  3. # license that can be found in the LICENSE file.
  4. if [ -d "./.git" ]; then
  5. last_commit="$(git rev-parse HEAD 2>/dev/null)"
  6. last_tag="$(git describe --tags --abbrev=0 2>/dev/null)"
  7. if [ -n "$last_tag" ]; then
  8. last_tag_commit="$(git rev-list -n 1 "$last_tag" 2>/dev/null)"
  9. echo "$last_commit" > commit_data.txt
  10. echo "$last_tag" > tag_data.txt
  11. echo "$last_tag_commit" > tag_commit_data.txt
  12. else
  13. echo "$last_commit" > commit_data.txt
  14. touch tag_data.txt
  15. touch tag_commit_data.txt
  16. fi
  17. else
  18. touch commit_data.txt
  19. touch tag_data.txt
  20. touch tag_commit_data.txt
  21. fi
  22. touch "VERSION"