Skip to content
Snippets Groups Projects
Commit 8088a7e0 authored by alexandre.caldato's avatar alexandre.caldato
Browse files

add script to generate commit md file

parent 7a0ba68f
No related branches found
No related tags found
No related merge requests found
## Latest Commit
**Branch name:** main
**Message:** Merge remote-tracking branch 'origin/main'
**Author:** alexandre.caldato
**Date:** 2023-06-01 19:13:51
from git import Repo
def get_git_commit_info(repo_path):
repo = Repo(repo_path)
head_commit = repo.head.commit
branch_name = repo.active_branch.name
return {
'branch': branch_name,
'message': head_commit.message,
'author': head_commit.author.name,
'date': head_commit.committed_datetime.strftime("%Y-%m-%d %H:%M:%S")
}
def generate_md_file(commit_info, output_file):
with open(output_file, 'w') as file:
file.write(f"## Latest Commit\n\n")
file.write(f"**Branch name:** {commit_info['branch']}\n\n")
file.write(f"**Message:** {commit_info['message']}\n\n")
file.write(f"**Author:** {commit_info['author']}\n\n")
file.write(f"**Date:** {commit_info['date']}\n\n")
if __name__ == "__main__":
repo_path = '.'
output_file = 'docs/commit_info.md'
commit_info = get_git_commit_info(repo_path)
generate_md_file(commit_info, output_file)
site_name: My Docs site_name: My Docs
nav:
- Home: index.md
- Latest Commit: commit_info.md
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment