fix: 修改commit提交日期,直接修改成当天

This commit is contained in:
OBKoro1 2020-12-22 18:16:33 +08:00
parent b677b27621
commit aa61a673bc

View File

@ -2,8 +2,8 @@
* Author : OBKoro1 * Author : OBKoro1
* Date : 2019-12-30 16:59:30 * Date : 2019-12-30 16:59:30
* LastEditors : OBKoro1 * LastEditors : OBKoro1
* LastEditTime : 2020-12-10 23:46:26 * LastEditTime : 2020-12-22 18:15:36
* FilePath : \autoCommit\src\models\commitHandle.ts * File : \autoCommit\src\models\commitHandle.ts
* Description : commit * Description : commit
* https://github.com/OBKoro1 * https://github.com/OBKoro1
*/ */
@ -159,6 +159,7 @@ class CommitHandle {
async commitFn() { async commitFn() {
await outputLog('将要commit的日期:', JSON.stringify(this.timeArr)); await outputLog('将要commit的日期:', JSON.stringify(this.timeArr));
outputLog('总commit天数:', this.timeArr.length);
outputLog('总commit次数:', this.totalCommit); outputLog('总commit次数:', this.totalCommit);
let totalNum = 0; // 总commit次数 let totalNum = 0; // 总commit次数
// 遍历日期 // 遍历日期
@ -183,7 +184,8 @@ class CommitHandle {
// 异步执行命令 让出线程 打印日志 等 // 异步执行命令 让出线程 打印日志 等
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
commitMsg = await new Promise((resolve, reject) => { commitMsg = await new Promise((resolve, reject) => {
const cmd = `git add . && git commit -m '${this.paramsObj.commitMsg}' --date='${time}'`; // 先提交commit 再修改commit日期和时间
const cmd = `git add . && git commit -m '${this.paramsObj.commitMsg}' && GIT_COMMITTER_DATE='${time}' GIT_AUTHOR_DATE='${time}' git commit --amend --no-edit --date '${time}'`;
exec(cmd, { exec(cmd, {
encoding: 'utf8', encoding: 'utf8',
cwd: this.paramsObj.itemSrc, cwd: this.paramsObj.itemSrc,
@ -243,7 +245,7 @@ class CommitHandle {
outputLog('提交中...'); outputLog('提交中...');
this.autoCommitView.postMessage('提交中...', '提交中'); this.autoCommitView.postMessage('提交中...', '提交中');
const res = await new Promise((resolve, reject) => { const res = await new Promise((resolve, reject) => {
const cmd = 'git pull && git push'; const cmd = 'git pull --rebase && git push';
exec(cmd, { exec(cmd, {
encoding: 'utf8', encoding: 'utf8',
cwd: this.paramsObj.itemSrc, cwd: this.paramsObj.itemSrc,