Skip to content

Instantly share code, notes, and snippets.

@icodragon
Last active July 26, 2023 11:21
Show Gist options
  • Select an option

  • Save icodragon/83452a0509b62276e97f022cfe043561 to your computer and use it in GitHub Desktop.

Select an option

Save icodragon/83452a0509b62276e97f022cfe043561 to your computer and use it in GitHub Desktop.
Create fake commit (fun)
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