From 8088a7e05ee9e0b05f4026f127cbd86963dadb06 Mon Sep 17 00:00:00 2001
From: "alexandre.caldato" <alexandre.caldato@sully-group.fr>
Date: Thu, 1 Jun 2023 19:50:17 +0200
Subject: [PATCH] add script to generate commit md file

---
 docs/commit_info.md     | 11 +++++++++++
 generate_commit_info.py | 29 +++++++++++++++++++++++++++++
 mkdocs.yml              |  3 +++
 3 files changed, 43 insertions(+)
 create mode 100644 docs/commit_info.md
 create mode 100644 generate_commit_info.py

diff --git a/docs/commit_info.md b/docs/commit_info.md
new file mode 100644
index 0000000..c159130
--- /dev/null
+++ b/docs/commit_info.md
@@ -0,0 +1,11 @@
+## Latest Commit
+
+**Branch name:** main
+
+**Message:** Merge remote-tracking branch 'origin/main'
+
+
+**Author:** alexandre.caldato
+
+**Date:** 2023-06-01 19:13:51
+
diff --git a/generate_commit_info.py b/generate_commit_info.py
new file mode 100644
index 0000000..6ecb233
--- /dev/null
+++ b/generate_commit_info.py
@@ -0,0 +1,29 @@
+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)
diff --git a/mkdocs.yml b/mkdocs.yml
index c97182f..7606ae7 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -1 +1,4 @@
 site_name: My Docs
+nav:
+  - Home: index.md
+  - Latest Commit: commit_info.md
-- 
GitLab