The Random Commit GitHub Bot is a Python script that automates the process of creating a new private GitHub repository (if it doesn't already exist) and making commits at random dates from 1 year in the past to the present.
- The script authenticates with the GitHub API using a Personal Access Token (PAT).
- It checks if the specified repository already exists for the authenticated user.
- If the repository does not exist, the script creates a new private repository.
- The script clones the repository to the local machine.
- The script makes commits at random dates in the past year. The date for each commit is randomly generated within a time range from 1 year ago to the current date.
- Finally, the script pushes the commits to the remote repository on GitHub.
-
Install the
PyGithub
library, which provides a Python interface for the GitHub API:pip install PyGithub
-
Clone this repository or download the Python script.
-
Generate a Personal Access Token (PAT) on GitHub with the "repo" scope. Instructions on how to create a PAT can be found in the GitHub documentation.
-
Replace the placeholder
YOUR_PERSONAL_ACCESS_TOKEN
in the Python script with your actual PAT. -
Run the script:
python random_commit_bot.py
The time complexity of the script is mainly determined by the number of commits it makes and the time it takes to push these commits to the remote repository. The time complexity is O(n) where n is the number of commits.
The space complexity is O(1) as the script uses a constant amount of space regardless of the number of commits.
- Python 3.x
PyGithub
librarygit
command line tool
- The script uses the
subprocess
module to run git commands. - The script manipulates the
GIT_AUTHOR_DATE
andGIT_COMMITTER_DATE
environment variables to set the date for each commit. - The date for each commit is randomly generated within a time range from 1 year ago to the current date.
- The script assumes that the repository does not have any uncommitted changes when it runs.
- Please be aware that making commits with previous dates will rewrite the commit history, which might not be desirable in all cases.
- The script is intended for educational purposes and should be used responsibly.
This project is licensed under the MIT License.