Your idea of inspecting the timestamps of the commits is conceptually flawed. Git is a distributed version control system, with no central server or any other means of notarizing timestamps. The timestamps are determined solely by the system clock on the machine on which the commit was created, and that clock can be trivially rolled back. Therefore, the only foolproof approach is to clone/pull all of the repositories at the time of the deadline.
Then, there is the question of which branch you want to inspect. Do you want to consider only the master
branch? If so, it would be a good idea to specify the master
branch when running git log
. Keep in mind that if you consider all commits that were created before the deadline, you may end up taking a commit that was rolled back by the student. In other words, if the student makes a commit, then changes her mind (using git reset --hard HEAD^
), you may be misconstruing the discarded version as the submission, simply because it has a later timestamp. For that reason, I hope that you only inspect commits along an agreed-upon branch or tag, rather than everything that might happen to exist in the repository.
In get_commit_hash()
, you use the %ad
pretty-printing format to obtain commit_timestamp
. That's a misnomer, as %ad
gets the authorship timestamp, not the commit timestamp. I believe you should be more interested in the commit timestamp. (Authorship times aren't even necessarily monotonic as you progress through the commit chain, since commits can be rearranged using git rebase
.)
Assuming that you still want to go through with your original plan, you're working too hard. This should get you the hash of the latest commit on the master
branch with a commit date in 2013:
git log -n 1 --until='2013-12-31 23:59:59' --pretty=%H master
Better yet, read what gitrevisions(1)
says about "the value of the ref at a point in time", and skip all that analysis.
git checkout 'master@{2013年12月31日 23:59:59}'
By the way, I strongly recommend that you abandon your date format in favour of ISO 8601.
XKCD 1179 http://imgs.xkcd.com/comics/iso_8601.pngXKCD 1179
Credit: https://xkcd.com/1179/
Your idea of inspecting the timestamps of the commits is conceptually flawed. Git is a distributed version control system, with no central server or any other means of notarizing timestamps. The timestamps are determined solely by the system clock on the machine on which the commit was created, and that clock can be trivially rolled back. Therefore, the only foolproof approach is to clone/pull all of the repositories at the time of the deadline.
Then, there is the question of which branch you want to inspect. Do you want to consider only the master
branch? If so, it would be a good idea to specify the master
branch when running git log
. Keep in mind that if you consider all commits that were created before the deadline, you may end up taking a commit that was rolled back by the student. In other words, if the student makes a commit, then changes her mind (using git reset --hard HEAD^
), you may be misconstruing the discarded version as the submission, simply because it has a later timestamp. For that reason, I hope that you only inspect commits along an agreed-upon branch or tag, rather than everything that might happen to exist in the repository.
In get_commit_hash()
, you use the %ad
pretty-printing format to obtain commit_timestamp
. That's a misnomer, as %ad
gets the authorship timestamp, not the commit timestamp. I believe you should be more interested in the commit timestamp. (Authorship times aren't even necessarily monotonic as you progress through the commit chain, since commits can be rearranged using git rebase
.)
Assuming that you still want to go through with your original plan, you're working too hard. This should get you the hash of the latest commit on the master
branch with a commit date in 2013:
git log -n 1 --until='2013-12-31 23:59:59' --pretty=%H master
Better yet, read what gitrevisions(1)
says about "the value of the ref at a point in time", and skip all that analysis.
git checkout 'master@{2013年12月31日 23:59:59}'
By the way, I strongly recommend that you abandon your date format in favour of ISO 8601.
XKCD 1179 http://imgs.xkcd.com/comics/iso_8601.png
Credit: https://xkcd.com/1179/
Your idea of inspecting the timestamps of the commits is conceptually flawed. Git is a distributed version control system, with no central server or any other means of notarizing timestamps. The timestamps are determined solely by the system clock on the machine on which the commit was created, and that clock can be trivially rolled back. Therefore, the only foolproof approach is to clone/pull all of the repositories at the time of the deadline.
Then, there is the question of which branch you want to inspect. Do you want to consider only the master
branch? If so, it would be a good idea to specify the master
branch when running git log
. Keep in mind that if you consider all commits that were created before the deadline, you may end up taking a commit that was rolled back by the student. In other words, if the student makes a commit, then changes her mind (using git reset --hard HEAD^
), you may be misconstruing the discarded version as the submission, simply because it has a later timestamp. For that reason, I hope that you only inspect commits along an agreed-upon branch or tag, rather than everything that might happen to exist in the repository.
In get_commit_hash()
, you use the %ad
pretty-printing format to obtain commit_timestamp
. That's a misnomer, as %ad
gets the authorship timestamp, not the commit timestamp. I believe you should be more interested in the commit timestamp. (Authorship times aren't even necessarily monotonic as you progress through the commit chain, since commits can be rearranged using git rebase
.)
Assuming that you still want to go through with your original plan, you're working too hard. This should get you the hash of the latest commit on the master
branch with a commit date in 2013:
git log -n 1 --until='2013-12-31 23:59:59' --pretty=%H master
Better yet, read what gitrevisions(1)
says about "the value of the ref at a point in time", and skip all that analysis.
git checkout 'master@{2013年12月31日 23:59:59}'
By the way, I strongly recommend that you abandon your date format in favour of ISO 8601.
XKCD 1179
Credit: https://xkcd.com/1179/
Your idea of inspecting the timestamps of the commits is conceptually flawed. Git is a distributed version control system, with no central server or any other means of notarizing timestamps. The timestamps are determined solely by the system clock on the machine on which the commit was created, and that clock can be trivially rolled back. Therefore, the only foolproof approach is to clone/pull all of the repositories at the time of the deadline.
Then, there is the question of which branch you want to inspect. Do you want to consider only the master
branch? If so, it would be a good idea to specify the master
branch when running git log
. Keep in mind that if you consider all commits that were created before the deadline, you may end up taking a commit that was rolled back by the student. In other words, if the student makes a commit, then changes her mind (using git reset --hard HEAD^
), you may be misconstruing the discarded version as the submission, simply because it has a later timestamp. For that reason, I hope that you only inspect commits along an agreed-upon branch or tag, rather than everything that might happen to exist in the repository.
In get_commit_hash()
, you use the %ad
pretty-printing format to obtain commit_timestamp
. That's a misnomer, as %ad
gets the authorship timestamp, not the commit timestamp. I believe you should be more interested in the commit timestamp. (Authorship times aren't even necessarily monotonic as you progress through the commit chain, since commits can be rearranged using git rebase
.)
Assuming that you still want to go through with your original plan, you're working too hard. This should get you the hash of the latest commit on the master
branch with a commit date in 2013:
git log -n 1 --until='2013-12-31 23:59:59' --pretty=%H master
Better yet, read what gitrevisions(1)
says about "the value of the ref at a point in time", and skip all that analysis.
git checkout 'master@{2013年12月31日 23:59:59}'
By the way, I strongly recommend that you abandon your date format in favour of ISO 8601.
XKCD 1179 http://imgs.xkcd.com/comics/iso_8601.png
Credit: https://xkcd.com/1179/