1
📥
Parse git commitsAmbil log deployment dari repo
2
🔍
Extract metadataFile, change, author, timestamp
3
📝
Format changelogJana senarai perubahan terkini
4
📊
Generate reportPaparkan ringkasan ke dashboard
import subprocess, json
def get_git_log():
result = subprocess.run(
['git', 'log', '--oneline', '-n', '20'],
capture_output=True, text=True
)
return result.stdout.strip().split('\n')
def parse_commits(lines):
logs = []
for line in lines:
if line:
parts = line.split(' ', 1)
hash_id = parts[0]
msg = parts[1] if len(parts) > 1 else ''
logs.append({
'file': msg.split(':')[0] if ':' in msg else 'unknown',
'change': msg.split(':', 1)[1].strip() if ':' in msg else msg,
'author': 'dev',
'time': '10:00',
'status': 'Deployed'
})
return logs
changelog = parse_commits(get_git_log())
print(json.dumps(changelog, indent=2))