|
| 1 | +const { exec } = require("child_process"); |
| 2 | +const moment = require("moment"); |
| 3 | + |
| 4 | +const yargs = require("yargs/yargs"); |
| 5 | +const { hideBin } = require("yargs/helpers"); |
| 6 | + |
| 7 | +const singleUser = () => { |
| 8 | + const argv = yargs(hideBin(process.argv)).argv; |
| 9 | + |
| 10 | + const userEmail = argv.userMail; |
| 11 | + |
| 12 | + console.log(`User email: ${argv.userMail}`); |
| 13 | + |
| 14 | + let todayDate = new Date(); |
| 15 | + |
| 16 | + let startingDate = new Date(); |
| 17 | + startingDate.setDate(todayDate.getDate() - todayDate.getDay()); |
| 18 | + |
| 19 | + startingDate.setDate(startingDate.getDate() - 1); |
| 20 | + |
| 21 | + let limitDate = new Date(); |
| 22 | + limitDate.setDate(startingDate.getDate() + 1); |
| 23 | + |
| 24 | + console.log(todayDate, startingDate); |
| 25 | + |
| 26 | + while (todayDate.getDate() !== startingDate.getDate()) { |
| 27 | + const startingDateFormat = moment(startingDate).format("YYYY-M-D"); |
| 28 | + const limitDateFormat = moment(limitDate).format("YYYY-M-D"); |
| 29 | + |
| 30 | + console.log(`Task List ${startingDateFormat} \n`); |
| 31 | + |
| 32 | + const gitCommand = `git log --pretty=format:'%s' --author="${userEmail}" --after="${startingDateFormat}" --before="${limitDateFormat}"`; |
| 33 | + |
| 34 | + exec(gitCommand, (err, stdout, stderr) => { |
| 35 | + const commitMsg = stdout.split(" ").slice(1).join(" "); |
| 36 | + |
| 37 | + console.log(commitMsg); |
| 38 | + }); |
| 39 | + |
| 40 | + startingDate.setDate(startingDate.getDate() + 1); |
| 41 | + |
| 42 | + limitDate.setDate(startingDate.getDate() + 1); |
| 43 | + } |
| 44 | +}; |
| 45 | + |
| 46 | +module.exports = singleUser; |
0 commit comments