|
14 | 14 | "Authorization": f"token {token}"
|
15 | 15 | }
|
16 | 16 |
|
17 |
| - # Get the latest commit details |
18 |
| - commit_url = f"https://api.github.com/repos/{handle}/{sys.argv[1]}/commits?sha=main" |
| 17 | + # Specify the correct repository here for commit fetching |
| 18 | + repo_name = "Hunterdii/GeeksforGeeks-POTD" # Correct repo |
| 19 | + commit_url = f"https://api.github.com/repos/{repo_name}/commits?sha=main" |
| 20 | + |
| 21 | + # Fetch the latest commit for the correct repo |
19 | 22 | response = requests.get(commit_url, headers=headers)
|
20 | 23 |
|
21 | 24 | if response.status_code != 200:
|
|
26 | 29 | commit_sha = commit_data['sha']
|
27 | 30 | commit_message = commit_data['commit']['message']
|
28 | 31 | commit_date = commit_data['commit']['committer']['date']
|
29 |
| - |
| 32 | + |
30 | 33 | # Extract the question name or solution identifier from the commit message (example: "01(Nov) Solution Name")
|
31 | 34 | solution_identifier = commit_message.split(":")[0] # Assuming commit message starts with the identifier
|
32 |
| - |
| 35 | + |
| 36 | + # Define the daily solution file path (e.g., "01(Nov)question_name.md") |
| 37 | + solution_file_path = f"{solution_identifier}question_name.md" |
| 38 | + |
33 | 39 | # Generate the badge URL dynamically based on the solution
|
34 | 40 | badge_url = f"https://img.shields.io/badge/Solution-{solution_identifier}-blue"
|
35 |
| - badge_link = f"[](https://github.com/{handle}/{sys.argv[1]}/commit/{commit_sha})" |
| 41 | + badge_link = f"[](https://github.com/{repo_name}/commit/{commit_sha})" |
36 | 42 |
|
37 | 43 | # Prepare the commit link
|
38 |
| - commit_link = f"Commit URL: https://github.com/{handle}/{sys.argv[1]}/commit/{commit_sha}" |
| 44 | + commit_link = f"Commit URL: https://github.com/{repo_name}/commit/{commit_sha}" |
39 | 45 |
|
40 | 46 | # Update README with the new commit and badge
|
41 | 47 | with open(readmePath, "r") as readme:
|
|
49 | 55 | with open(readmePath, "w") as readme:
|
50 | 56 | readme.write(new_content)
|
51 | 57 |
|
52 |
| - print("Successfully updated README with the latest commit and badge.") |
| 58 | + # Create or update the daily solution file (e.g., "01(Nov)question_name.md") |
| 59 | + with open(solution_file_path, "w") as solution_file: |
| 60 | + solution_file.write(f"# Solution for {solution_identifier}\n\nThis is the solution for {solution_identifier}. Commit link: [Commit]({commit_link})\n") |
| 61 | + |
| 62 | + print(f"Successfully updated README with the latest commit, badge, and created {solution_file_path}.") |
0 commit comments