get_github_push_date.sh 636 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. echo -n "Enter your GitHub username: "
  3. read username
  4. echo -n "Enter the owner of the repository: "
  5. read owner
  6. echo -n "Enter the name of the repository: "
  7. read repo
  8. echo -n "Enter the commit SHA: "
  9. read sha
  10. node_id=$(curl \
  11. "https://api.github.com/repos/${owner}/${repo}/commits/${sha}" \
  12. 2> /dev/null | grep node_id | head -n1 | sed 's@^.*"\(.*\)".*$@\1@')
  13. echo $node_id
  14. curl -u "${username}" -X POST -d " \
  15. { \
  16. \"query\": \"query { \
  17. node(id: \\\"${node_id}\\\") { \
  18. ... on Commit { \
  19. message \
  20. pushedDate \
  21. } \
  22. } \
  23. }\" \
  24. } " https://api.github.com/graphql