In [1]:
# Code attribution: Yiyin Shen, Tyler Caraza-Harter
# Imports
import re
import matplotlib.pyplot as plt
In [2]:
# Run "git log > git-log.txt" to get the text file containing the git log of CS320-F23 repo.
with open("git-log.txt", encoding='utf-16') as f:
    text = f.read()
re.findall(r"(Date:.*)\n", text)[0:10]
Out[2]:
['Date:   Sun Oct 29 20:32:39 2023 -0500',
 'Date:   Sun Oct 29 20:29:27 2023 -0500',
 'Date:   Sun Oct 29 20:28:57 2023 -0500',
 'Date:   Tue Oct 24 07:02:14 2023 +0000',
 'Date:   Tue Oct 24 07:02:07 2023 +0000',
 'Date:   Sun Oct 22 11:40:10 2023 -0500',
 'Date:   Sun Oct 22 11:39:41 2023 -0500',
 'Date:   Thu Oct 19 08:01:05 2023 +0000',
 'Date:   Thu Oct 19 00:59:41 2023 +0000',
 'Date:   Thu Oct 19 00:59:34 2023 +0000']
In [3]:
# Replace months in the dates by numbers
copy = text
months = {" Aug ": " 08 ", " Sep ": " 09 ", " Oct ": " 10 "}
for m in months.items():
    copy = re.sub(m[0], m[1], copy)
re.findall(r"(Date:.*)\n", copy)[0:10]
Out[3]:
['Date:   Sun 10 29 20:32:39 2023 -0500',
 'Date:   Sun 10 29 20:29:27 2023 -0500',
 'Date:   Sun 10 29 20:28:57 2023 -0500',
 'Date:   Tue 10 24 07:02:14 2023 +0000',
 'Date:   Tue 10 24 07:02:07 2023 +0000',
 'Date:   Sun 10 22 11:40:10 2023 -0500',
 'Date:   Sun 10 22 11:39:41 2023 -0500',
 'Date:   Thu 10 19 08:01:05 2023 +0000',
 'Date:   Thu 10 19 00:59:41 2023 +0000',
 'Date:   Thu 10 19 00:59:34 2023 +0000']
In [4]:
# Replace dates by day/month/year format
final = re.sub(r"\w{3}\s(\d{2})\s(\d{2})\s(\d{2}:\d{2}:\d{2})\s(\d{4})\s[\+-]\d{4}", "\g<2>/\g<1>/\g<4>,   Time:   \g<3>", copy)
re.findall(r"(Date:.*)\n", final)[0:10]
Out[4]:
['Date:   29/10/2023,   Time:   20:32:39',
 'Date:   29/10/2023,   Time:   20:29:27',
 'Date:   29/10/2023,   Time:   20:28:57',
 'Date:   24/10/2023,   Time:   07:02:14',
 'Date:   24/10/2023,   Time:   07:02:07',
 'Date:   22/10/2023,   Time:   11:40:10',
 'Date:   22/10/2023,   Time:   11:39:41',
 'Date:   19/10/2023,   Time:   08:01:05',
 'Date:   19/10/2023,   Time:   00:59:41',
 'Date:   19/10/2023,   Time:   00:59:34']
In [5]:
print(final[0:320])
commit ff8d4fcfdaf6dac2ba5a0c52c166af7fdb6e3c7d
Author: Young Wu <wu489@wisc.edu>
Date:   29/10/2023,   Time:   20:32:39

    Add files via upload

commit 61f95acad3436190c914c8466fa292bba752190b
Author: Young Wu <wu489@wisc.edu>
Date:   29/10/2023,   Time:   20:29:27

    Update README.md

commit 5a0d3a025c02aaea5c066