인턴 메모

GitHub File SHA Hash Test

csb0710 2024. 7. 5. 23:19

개요

‘수집한 GitHub 파일의 중복 유무를 SHA에 나타난 Hash 값을 이용하는 건 어떨까?’ 하는 아이디어를 위한 테스트

 

진행

테스트 레포(https://github.com/csb0710/git_api_test/tree/main) 생성 후 진행

레포지토리의 컨텐츠들을 가져오는 git api 활용

$  curl -L \\
  -H "Accept: application/vnd.github+json" \\
  -H "Authorization: Bearer github_pat_toooooooooooookeeeeeeeeeeeeeen" \\
  -H "X-GitHub-Api-Version: 2022-11-28" \\
  <https://api.github.com/repos/csb0710/git_api_test/contents>

 

결과


  • test.md의 SHA 값: 90052478cb743373c8e7c79871f063d26e01c8d1


  • test.md에 내용 추가 후

  • test.md의 SHA 값: bfe40d1fb0b5b765cbba34894d049c79dd0ecaab


  • test.md의 파일 크기는 유지한 채 내용 변경

  • test.md의 SHA 값: 3192b6bb18ff0195bc8d0992385961a7d6f74409


 

결론

SHA 값은 파일이 생성/변경 될 때마다 Git에 의해 매번 다시 계산 되는 것을 확인