MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / parse_git_log

Function parse_git_log

visualize_programming_time.py:15–58  ·  view source on GitHub ↗

Get git log data and parse into structured format.

()

Source from the content-addressed store, hash-verified

13
14
15def parse_git_log():
16 """Get git log data and parse into structured format."""
17 try:
18 result = subprocess.run(
19 ["git", "log", "--pretty=format:%H|%ad|%s", "--date=iso", "--all"],
20 capture_output=True,
21 text=True,
22 cwd=".",
23 )
24
25 if result.returncode != 0:
26 print("Error running git log command")
27 return []
28
29 commits = []
30 lines = result.stdout.strip().split("\n")
31
32 for line in lines:
33 if "|" in line:
34 parts = line.split("|", 2)
35 if len(parts) >= 3:
36 commit_hash = parts[0]
37 date_str = parts[1].strip()
38 message = parts[2]
39
40 try:
41 dt = datetime.strptime(date_str, "%Y-%m-%d %H:%M:%S %z")
42 commits.append(
43 {
44 "hash": commit_hash,
45 "datetime": dt,
46 "message": message,
47 "date_str": date_str,
48 }
49 )
50 except ValueError as e:
51 print(f"Error parsing date '{date_str}': {e}")
52
53 commits.sort(key=lambda x: x["datetime"])
54 return commits
55
56 except Exception as e:
57 print(f"Error getting git log: {e}")
58 return []
59
60
61def calculate_programming_sessions(commits, max_gap_minutes=120):

Callers 1

mainFunction · 0.70

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected