How do I get the revision number of a commit? As an example may the number of the following commit
https://github.com/FreeCAD/FreeCAD_sf_m ... 520e05e9e2
It should be around 2600
Code: Select all
git rev-list <sha1> | wc -l
Code: Select all
git rev-list f654c632ba9366ba2527284424469d520e05e9e2 | wc -l
Ahh, I knew about the sh1 values. Counting the newlines ... That is why I couldn'd find anything in my git book. Thanks Wernerwmayer wrote:...To extract some kind of revision number which humans understand better we count the number of newlines of all listed sha1 values. So, to get this information you have to:...Code: Select all
git rev-list <sha1> | wc -l
Code: Select all
https://github.com/FreeCAD/FreeCAD/tree/Put_in_the_commitID
Code: Select all
[przemo@localhost freecad]$ git rev-list --count f654c632ba9366ba2527284424469d520e05e9e2
2655
It's two lines. You know you can just post it in this thread inside code tags...openBrain wrote: ↑Fri Dec 27, 2019 7:06 pmI issued a very simple way to get it at HEAD or at a specific SHA.
Code: Select all
curl -I -k "https://api.github.com/repos/:owner/:repo/commits?per_page=1" | sed -n '/^Link:/ s/.*"next".*page=\([0-9]*\).*"last".*/\1/p'
### And that's all !
# I saw many fighting with finding first commit SHA or similar fancy thing.
# Here we just rely on the GH API, asking commits at 1 per page and parsing the last page number in the header of the reply (whose body only holds the last commit !)
# So this is robust and bandwidth efficient. :)
# If one want the commit count of a specific SHA, just use :
curl -I -k "https://api.github.com/repos/:owner/:repo/commits?per_page=1&sha=:sha" | sed -n '/^Link:/ s/.*"next".*page=\([0-9]*\).*"last".*/\1/p'