diff --git a/src/update_commit.py b/src/update_commit.py index f0a7f263..97ef2a38 100644 --- a/src/update_commit.py +++ b/src/update_commit.py @@ -1,22 +1,25 @@ + import requests import sys import re from datetime import datetime if __name__ == "__main__": - assert(len(sys.argv) == 5) + assert(len(sys.argv) == 4) repository = sys.argv[1] token = sys.argv[2] readme_path = sys.argv[3] - file_name = sys.argv[4] # The filename is now passed dynamically # 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 URL for today (dynamically from the file_name) - solution_url = f"https://github.com/{repository}/blob/main/November%202024%20GFG%20SOLUTION/{file_name}" + # Prepare the solution filename for today (e.g., 06(Nov)Root to leaf paths sum.md) + 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" @@ -26,6 +29,14 @@ with open(readme_path, "r") as readme: content = readme.read() + # Update today's solution link (for the commit) + # content = re.sub( + # r"(?<=).*?(?=)", + # f"\n{solution_url}\n", + # content, + # flags=re.DOTALL + # ) + # Update badge link content = re.sub( r"(?<=).*?(?=)",