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