This project automates the process of making multiple git commits with random dates within the past year. It uses the jsonfile, moment, simple-git, and random libraries to achieve this functionality.
jsonfile: For reading and writing JSON files.moment: For manipulating and formatting dates.simple-git: For interacting with Git.random: For generating random numbers.
To install the dependencies, run:
npm installTo use this script, simply call the markCommit function with the desired number of commits. For example:
markCommit(50);This function creates a git commit with a random date within the past year. It recursively calls itself to create multiple commits.
n(number): The number of commits to create. Ifnis 0, the function will push the commits to the remote repository.
- If
nis 0, the function pushes the commits to the remote repository and returns. - Generates a random date within the past year.
- Creates a data object with the generated date.
- Logs the commit date to the console.
- Writes the date to the JSON file specified by
path. - Adds the JSON file to the git staging area.
- Commits the changes with the generated date.
- Recursively calls itself with
n - 1to create the next commit.