mirror of
https://github.com/xuexb/github-bot.git
synced 2026-01-18 13:56:38 +00:00
fix: update git clone git-pull-or-clone
This commit is contained in:
parent
c5e7605da4
commit
af69972fed
99
package.json
99
package.json
@ -1,50 +1,59 @@
|
||||
{
|
||||
"name": "github-bot",
|
||||
"description": "Github bot",
|
||||
"version": "0.0.1",
|
||||
"main": "src/app.js",
|
||||
"scripts": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/xuexb/github-bot.git"
|
||||
"name": "github-bot",
|
||||
"description": "Github bot",
|
||||
"version": "0.0.1",
|
||||
"main": "src/app.js",
|
||||
"scripts": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/xuexb/github-bot.git"
|
||||
},
|
||||
"author": "xuexb <fe.xiaowu@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/xuexb/github-bot/issues"
|
||||
},
|
||||
"homepage": "https://github.com/xuexb/github-bot#readme",
|
||||
"dependencies": {
|
||||
"cryptiles": "3.1.2",
|
||||
"crypto": "^1.0.1",
|
||||
"dotenv": "^4.0.0",
|
||||
"github": "^11.0.0",
|
||||
"koa": "^2.3.0",
|
||||
"koa-bodyparser": "^4.2.0",
|
||||
"require-dir": "^0.3.2",
|
||||
"string-template": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
},
|
||||
"config": {
|
||||
"ghooks": {
|
||||
"commit-msg": "validate-commit-msg"
|
||||
},
|
||||
"author": "xuexb <fe.xiaowu@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/xuexb/github-bot/issues"
|
||||
"validate-commit-msg": {
|
||||
"types": [
|
||||
"feat",
|
||||
"fix",
|
||||
"docs",
|
||||
"style",
|
||||
"test",
|
||||
"chore",
|
||||
"revert",
|
||||
"close"
|
||||
]
|
||||
},
|
||||
"homepage": "https://github.com/xuexb/github-bot#readme",
|
||||
"dependencies": {
|
||||
"cryptiles": "3.1.2",
|
||||
"crypto": "^1.0.1",
|
||||
"dotenv": "^4.0.0",
|
||||
"github": "^11.0.0",
|
||||
"koa": "^2.3.0",
|
||||
"koa-bodyparser": "^4.2.0",
|
||||
"require-dir": "^0.3.2",
|
||||
"string-template": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
},
|
||||
"config": {
|
||||
"ghooks": {
|
||||
"commit-msg": "validate-commit-msg"
|
||||
},
|
||||
"validate-commit-msg": {
|
||||
"types": ["feat", "fix", "docs", "style", "test", "chore", "revert", "close"]
|
||||
},
|
||||
"github-bot": {
|
||||
"lableToAuthor": {
|
||||
"bug": "xuexb",
|
||||
"enhancement": "xuexb",
|
||||
"question": "xuexb"
|
||||
}
|
||||
}
|
||||
},
|
||||
"os": ["darwin", "linux"],
|
||||
"devDependencies": {
|
||||
"ghooks": "^2.0.0",
|
||||
"validate-commit-msg": "^2.14.0"
|
||||
"github-bot": {
|
||||
"lableToAuthor": {
|
||||
"bug": "xuexb",
|
||||
"enhancement": "xuexb",
|
||||
"question": "xuexb"
|
||||
}
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"ghooks": "^2.0.0",
|
||||
"git-pull-or-clone": "^1.1.0",
|
||||
"validate-commit-msg": "^2.14.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ module.exports = on => {
|
||||
body: body.join('\n')
|
||||
});
|
||||
}
|
||||
});
|
||||
}).catch(err => console.error(err));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
13
src/utils.js
13
src/utils.js
@ -9,6 +9,7 @@ const fs = require('fs');
|
||||
const crypto = require('crypto');
|
||||
const {fixedTimeComparison} = require('cryptiles');
|
||||
const {execSync, exec} = require('child_process');
|
||||
const gitPullOrClone = require('git-pull-or-clone');
|
||||
|
||||
const utils = {
|
||||
mentioned(body) {
|
||||
@ -85,22 +86,16 @@ const utils = {
|
||||
*
|
||||
* @return {Promise}
|
||||
*/
|
||||
updateRepo({repo}) {
|
||||
updateRepo({url, repo}) {
|
||||
const repoDir = path.resolve(__dirname, '../github/', repo);
|
||||
|
||||
if (!utils.isDirectory(repoDir)) {
|
||||
throw new Error(`${repoDir} 不是github目录!`);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(`cd ${repoDir} && git pull`, err => {
|
||||
gitPullOrClone(url, repoDir, err => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
resolve(repoDir);
|
||||
}, 1000);
|
||||
resolve(repoDir);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user