TASK: Get the last 5 git commit messages and summarize the changes in 'git_summary.md'.
|
||
----------------------------------------
|
||
Loading...
|
||
|
||
[1;34m┌─── Python Source Code ─────────────────────────────────────[0m
|
||
[1;34m│[0m [2m 1 |[0m [34mimport[0m[33m subprocess[0m
|
||
[1;34m│[0m [2m 2 |[0m # Get last [36m5[0m[33m git commit messages[0m
|
||
[1;34m│[0m [2m 3 |[0m result = subprocess.run(['git', 'log', '-n', '[36m5[0m[33m', '--pretty=format:%s'], capture_output=True, text=True)[0m
|
||
[1;34m│[0m [2m 4 |[0m commit_messages = result.stdout.strip().split('\n')[0m
|
||
[1;34m│[0m [2m 5 |[0m # Summarize changes[0m
|
||
[1;34m│[0m [2m 6 |[0m summary = "Last [36m5[0m[33m commits:\n" + "\n".join(commit_messages)[0m
|
||
[1;34m│[0m [2m 7 |[0m # Write to file[0m
|
||
[1;34m│[0m [2m 8 |[0m [34mwith[0m[33m open('git_summary.md', 'w') [34mas[0m[33m f:[0m
|
||
[1;34m│[0m [2m 9 |[0m f.write(summary)[0m
|
||
[1;34m└────────────────────────────────────────────────────────────[0m
|
||
The last five git commit messages have been retrieved and summarized in the file 'git_summary.md'.
|