Reputation: 32296
This curl command works as expected and shows when the repository was first created.
curl https://api.github.com/repos/RaRe-Technologies/gensim | grep created
"created_at": "2011-02-10T07:43:04Z",
But this does not show when a file in that repo was created.
curl https://api.github.com/repos/RaRe-Technologies/gensim/blob/develop/gensim/scripts/make_wikicorpus.py | grep created
Is there any way to find the date on which the file was introduced?
Upvotes: 2
Views: 71
Reputation: 1323125
The alternative, using GitHub CLI gh
, and its gh api
command:
# Windows
gh api -X GET repos/RaRe-Technologies/gensim/commits \
-f path="gensim/scripts/make_wikicorpus.py" \
--jq ".[-1].commit.author.date"
# Linux
gh api -X GET repos/RaRe-Technologies/gensim/commits \
-f path='gensim/scripts/make_wikicorpus.py' \
--jq '.[-1].commit.author.date'
2012-07-21T20:00:29Z
You don't even need jq
if you have gh
installed.
Upvotes: 1
Reputation: 1366
You can use https://api.github.com/repos/OWNER/REPO/commits?path=<path/to/file>
, as described here.
The results of this request can then be parsed by jq
, with the following options .[-1].commit.author.date
.
This tells jq
to get the last item of the array ([-1]
), and then parse the value of commit
, then author
and then the date
, which is the date of the commit.
So using the follwing command
curl "https://api.github.com/repos/RaRe-Technologies/gensim/commits?path=gensim/scripts/make_wikicor
pus.py" | jq -r ".[-1].commit.author.date"
will result in
2012-07-21T20:00:29Z
Upvotes: 2