diff --git a/.DS_Store b/.DS_Store index 79f0da6..885a430 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/CHANGELOG.md b/CHANGELOG.md index 37f1ef9..ace045e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,6 @@ ### 如果觉得本插件还不错的话,给个[Star](https://github.com/OBKoro1/autoCommit)吧~ - diff --git a/README.md b/README.md index cd50f86..fccf58f 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,6 @@ - + - \ No newline at end of file + \ No newline at end of file diff --git a/images/.DS_Store b/images/.DS_Store index 042fda9..6f910b0 100644 Binary files a/images/.DS_Store and b/images/.DS_Store differ diff --git a/images/command.png b/images/command.png new file mode 100644 index 0000000..ef70912 Binary files /dev/null and b/images/command.png differ diff --git a/images/icon.png b/images/icon.png index a187e7e..18681df 100644 Binary files a/images/icon.png and b/images/icon.png differ diff --git a/images/icon2.png b/images/icon2.png deleted file mode 100644 index c277b7f..0000000 Binary files a/images/icon2.png and /dev/null differ diff --git a/images/icon3.png b/images/icon3.png deleted file mode 100644 index 18681df..0000000 Binary files a/images/icon3.png and /dev/null differ diff --git a/package.json b/package.json index 029628b..50301db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "autoCommit", - "displayName": "autoCommit", + "name": "auto-commit", + "displayName": "Auto Commit", "description": "自动提交commit到github", "publisher": "OBKoro1", "version": "1.0.0", @@ -20,7 +20,7 @@ "email": "obkoro1@foxmail.com", "url": "http://obkoro1.com/web_accumulate/" }, - "icon": "images/icon3.png", + "icon": "images/icon.png", "galleryBanner": { "color": "#3B4859", "theme": "dark" @@ -44,8 +44,8 @@ "commands": [ { "command": "extension.autoCommit", - "title": "Github自动提交 autoCommit", - "category": "Github自动提交 autoCommit" + "title": "控制Github绿色格子的commit数量", + "category": "auto commit Github自动提交 " } ] }, diff --git a/src/index.js b/src/index.js deleted file mode 100644 index 69851e9..0000000 --- a/src/index.js +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Author : OBKoro1 - * Date : 2019-12-19 20:23:57 - * LastEditors : OBKoro1 - * LastEditTime : 2019-12-27 15:50:22 - * FilePath : /autoCommit/src/index.js - * Description : 自动commit - * https://github.com/OBKoro1 - */ - -const { execSync } = require('child_process'); -const moment = require('moment'); -const fs = require('fs'); - -class autoCommit { - constructor() { - this.init(); - } - getData() { - this.getAllDay(this.paramsObj.beginDay, this.paramsObj.endDay); - this.readyCommit(); - } - // 格式化日期 - formatTime(time) { - return `${time} 08:00`; - } - // 获取两个日期之间的间隔: [ '2019-02-02', '2019-02-03' ... ] - getAllDay(begin, end) { - this.timeArr = []; - const beginSplit = begin.split('-'); - const endSplit = end.split('-'); - const beginDate = new Date(); - beginDate.setUTCFullYear(beginSplit[0], beginSplit[1] - 1, beginSplit[2]); - const endDate = new Date(); - endDate.setUTCFullYear(endSplit[0], endSplit[1] - 1, endSplit[2]); - const beginNumber = beginDate.getTime(); - const endNumber = endDate.getTime(); - for (let k = beginNumber; k <= endNumber; ) { - const day = new Date(parseInt(k)); - const dayFormat = moment(day).format('YYYY-MM-DD'); - this.timeArr.push(dayFormat); - k = k + 24 * 60 * 60 * 1000; - } - } - init() { - // TODO: 获取参数 - let paramsObj = { - beginDay: '2019-12-27', - itemSrc: '/Users/koro/work/web_my/testCommit' // 要commit的项目地址 - }; - let defaultOption = { - beginDay: moment().format('YYYY-MM-DD'), // 默认为今天 - endDay: moment().format('YYYY-MM-DD'), // 默认为今天 - fileSrc: `commit.md`, - commitNumber: 1 // 每天commit 次数 - }; - this.paramsObj = Object.assign(defaultOption, paramsObj); - this.getData(); - } - // commit - readyCommit() { - console.log('日期数组:', this.timeArr); - console.log('每个日期提交次数:', this.paramsObj.commitNumber); - let totalNum = 0; // 总commit次数 - // 遍历日期 - this.timeArr.forEach(item => { - // 每个日期commit次数 - for (let i = 0; i < this.paramsObj.commitNumber; i++) { - let time = this.formatTime(item); // 2019-01-02 08:00 - time = moment(time).format(); // 2019-01-02T00:00:00+0800 - const commitContent = `${time}${i}`; - fs.writeFileSync( - `${this.paramsObj.itemSrc}/${this.paramsObj.fileSrc}`, - commitContent, - 'utf-8' - ); - let res = this.myExecSync( - `cd ${this.paramsObj.itemSrc} && git add . && git commit -m 'autoCommit' --date='${time}' && git pull && git push origin master` - ); - console.log('res 开始', res); - console.log('res 结束'); - let cmd = `git log -1 \ - --date=iso --pretty=format:'{"commit": "%h","author": "%aN <%aE>","date": "%ad","message": "%s"},' \ - $@ | \ - perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \ - perl -pe 's/},]/}]/'`; - let log = this.myExecSync(cmd); - console.log('log 开始', log); - console.log('log 结束'); - totalNum++; - - console.log('commit内容', commitContent); - } - console.log(`总commit次数${totalNum}`); - }); - } - - myExecSync(cmd) { - // 除了该方法直到子进程完全关闭后才返回 执行完毕 返回 - try { - const res = execSync(cmd, { - encoding: 'utf8', - timeout: 0, - maxBuffer: 200 * 1024, - killSignal: 'SIGTERM', - cwd: undefined, - env: undefined - }); - return res; - } catch (err) { - console.log(`执行命令出错:${cmd}`); - } - } -} - -new autoCommit(); diff --git a/vsc-extension-quickstart.md b/vsc-extension-quickstart.md deleted file mode 100644 index b510bff..0000000 --- a/vsc-extension-quickstart.md +++ /dev/null @@ -1,42 +0,0 @@ -# Welcome to your VS Code Extension - -## What's in the folder - -* This folder contains all of the files necessary for your extension. -* `package.json` - this is the manifest file in which you declare your extension and command. - * The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. -* `src/extension.ts` - this is the main file where you will provide the implementation of your command. - * The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. - * We pass the function containing the implementation of the command as the second parameter to `registerCommand`. - -## Get up and running straight away - -* Press `F5` to open a new window with your extension loaded. -* Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`. -* Set breakpoints in your code inside `src/extension.ts` to debug your extension. -* Find output from your extension in the debug console. - -## Make changes - -* You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`. -* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. - - -## Explore the API - -* You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`. - -## Run tests - -* Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`. -* Press `F5` to run the tests in a new window with your extension loaded. -* See the output of the test result in the debug console. -* Make changes to `src/test/suite/extension.test.ts` or create new test files inside the `test/suite` folder. - * The provided test runner will only consider files matching the name pattern `**.test.ts`. - * You can create folders inside the `test` folder to structure your tests any way you want. - -## Go further - - * Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension). - * [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VSCode extension marketplace. - * Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration).