//获取当前日期函数
function getNowFormatDate(type='end') {
let date = new Date(),
year = date.getFullYear(), //获取完整的年份(4位)
month = date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
strDate = date.getDate() // 获取当前日(1-31)
if (month < 10) month = `0${month}` // 如果月份是个位数,在前面补0
if (strDate < 10) strDate = `0${strDate}` // 如果日是个位数,在前面补0
if(type=="start"){
return `${year}-${month}-01`
}else{
return `${year}-${month}-${strDate}`
}
}
/**
* 看这里 你需要修改的是
*
* yourname
*
* 你需要在你所在的项目 右键 git Bash Here
*
* 本次统计的行数为 你此项目的 此分支 提交的代码量
*
* 把控制台打印的 log 复制 出来 执行
*
* **/
let yourname = "上海.吴义超",
now = new Date(),
startDate =getNowFormatDate('start'),
endDate= getNowFormatDate()
let gitLog = `git log --author="${yourname}" --since=${startDate} --until=${endDate} --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s", add, subs, loc }' -`
console.log(gitLog)
console