Skip to content

Commit 8ed32b2

Browse files
authored
Update update_commit.py
1 parent 0488381 commit 8ed32b2

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/update_commit.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,31 @@
1515

1616
# Get the current date
1717
today = datetime.today()
18-
day_of_month = today.strftime("%d") # Get current day of the month
19-
month = today.strftime("%B") # Get current full month name (e.g., November)
20-
21-
# Format the solution file name for today (e.g., 06(Nov)Root to leaf paths sum.md)
22-
today_solution_filename = f"{day_of_month}({today.strftime('%b')}){today.strftime('%A')}.md"
18+
day_of_month = today.strftime("%d") # Get current day of the month (e.g., 06)
19+
month = today.strftime("%b") # Get current month (e.g., Nov)
20+
21+
# Prepare the solution filename for today (e.g., 06(Nov)Root to leaf paths sum.md)
22+
# You can customize this to the exact naming pattern you use
23+
today_solution_filename = f"{day_of_month}({month}){today.strftime('%A')}.md"
2324

2425
# Prepare the badge URL and commit link to update README
2526
badge_url = "https://img.shields.io/badge/GeeksforGeeks-Solution%20of%20the%20Day-blue"
26-
badge_link = f"[![Today's POTD Solution]({badge_url})](https://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{today_solution_filename})"
27+
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)"
2728

2829
# Read the README file and update the sections for commit and badge
2930
with open(readme_path, "r") as readme:
3031
content = readme.read()
3132

32-
# Update today's solution link in the README
33+
# Update today's solution link (for the commit)
34+
solution_url = f"https://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{day_of_month}({month}){today.strftime('%A')}.md"
3335
content = re.sub(
3436
r"(?<=<!--START_SECTION:latest-commit-->).*?(?=<!--END_SECTION:latest-commit-->)",
35-
f"\nhttps://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{today_solution_filename}\n",
37+
f"\n{solution_url}\n",
3638
content,
3739
flags=re.DOTALL
3840
)
3941

40-
# Update the badge link
42+
# Update badge link
4143
content = re.sub(
4244
r"(?<=<!--START_SECTION:potd-badge-->).*?(?=<!--END_SECTION:potd-badge-->)",
4345
f"\n{badge_link}\n",

0 commit comments

Comments
 (0)