From 7e3cf29531dba403e7281e91d46a0a36a61e6604 Mon Sep 17 00:00:00 2001 From: Het Patel <124852522+Hunterdii@users.noreply.github.com> Date: Wed, 6 Nov 2024 22:49:16 +0530 Subject: [PATCH] Update update_commit.py --- src/update_commit.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/update_commit.py b/src/update_commit.py index 8925df04..acfe5306 100644 --- a/src/update_commit.py +++ b/src/update_commit.py @@ -9,29 +9,26 @@ token = sys.argv[2] readme_path = sys.argv[3] - headers = { - "Authorization": f"token {token}" - } - # Get the current date today = datetime.today() day_of_month = today.strftime("%d") # Get current day of the month (e.g., 06) month = today.strftime("%b") # Get current month (e.g., Nov) # Prepare the solution filename for today (e.g., 06(Nov)Root to leaf paths sum.md) - # You can customize this to the exact naming pattern you use today_solution_filename = f"{day_of_month}({month}){today.strftime('%A')}.md" + # Prepare the commit URL for today (we don't need to change this as it will be dynamically picked from the latest commit) + solution_url = f"https://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{today_solution_filename}" + # Prepare the badge URL and commit link to update README badge_url = "https://img.shields.io/badge/GeeksforGeeks-Solution%20of%20the%20Day-blue" - badge_link = f"[![Today's POTD Solution]({badge_url})](https://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{day_of_month}({month}){today.strftime('%A')}.md)" + badge_link = f"[![Today's POTD Solution]({badge_url})]({solution_url})" # This makes the badge link to the solution for today # Read the README file and update the sections for commit and badge with open(readme_path, "r") as readme: content = readme.read() # Update today's solution link (for the commit) - solution_url = f"https://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{day_of_month}({month}){today.strftime('%A')}.md" content = re.sub( r"(?<=).*?(?=)", f"\n{solution_url}\n",