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

Function parse_git_log

simple_time_analysis.py:12–57  ·  view source on GitHub ↗

Get git log data and parse into structured format.

()

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected