Last active
July 26, 2023 11:21
-
-
Save icodragon/83452a0509b62276e97f022cfe043561 to your computer and use it in GitHub Desktop.
Create fake commit (fun)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const util = require("util"); | |
| const { exec } = require("child_process"); | |
| const execAsync = util.promisify(exec); | |
| Date.prototype.addDays = function (days) { | |
| const date = new Date(this.valueOf()) | |
| date.setDate(date.getDate() + days) | |
| return date | |
| } | |
| function sleep(ms) { | |
| return new Promise((resolve) => { | |
| setTimeout(resolve, ms); | |
| }); | |
| } | |
| function random(min, max) { | |
| return Math.floor( | |
| Math.random() * (max - min + 1) + min | |
| ) | |
| } | |
| async function run() { | |
| const days = 10; | |
| let date = new Date('03-13-2022'); | |
| for (let i = 0; i < days; i++) { | |
| if (!random(0, 1)) continue; | |
| date = await date.addDays(1); | |
| console.log(date); | |
| await execAsync(`echo "Date commit: ${date}" > dates.txt`); | |
| await execAsync(`git add dates.txt`); | |
| console.log('Commit:', await execAsync(`git commit --quiet --date "${date}" -m "Pasted date"`)); | |
| await sleep(100); | |
| } | |
| } | |
| run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment