Skip to content

Commit 7e3cf29

Browse files
authored
Update update_commit.py
1 parent dbce1f6 commit 7e3cf29

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/update_commit.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,26 @@
99
token = sys.argv[2]
1010
readme_path = sys.argv[3]
1111

12-
headers = {
13-
"Authorization": f"token {token}"
14-
}
15-
1612
# Get the current date
1713
today = datetime.today()
1814
day_of_month = today.strftime("%d") # Get current day of the month (e.g., 06)
1915
month = today.strftime("%b") # Get current month (e.g., Nov)
2016

2117
# 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
2318
today_solution_filename = f"{day_of_month}({month}){today.strftime('%A')}.md"
2419

20+
# Prepare the commit URL for today (we don't need to change this as it will be dynamically picked from the latest commit)
21+
solution_url = f"https://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{today_solution_filename}"
22+
2523
# Prepare the badge URL and commit link to update README
2624
badge_url = "https://img.shields.io/badge/GeeksforGeeks-Solution%20of%20the%20Day-blue"
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)"
25+
badge_link = f"[![Today's POTD Solution]({badge_url})]({solution_url})" # This makes the badge link to the solution for today
2826

2927
# Read the README file and update the sections for commit and badge
3028
with open(readme_path, "r") as readme:
3129
content = readme.read()
3230

3331
# 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"
3532
content = re.sub(
3633
r"(?<=<!--START_SECTION:latest-commit-->).*?(?=<!--END_SECTION:latest-commit-->)",
3734
f"\n{solution_url}\n",

0 commit comments

Comments
 (0)