Skip to content

Commit af69972

Browse files
committed
fix: update git clone git-pull-or-clone
1 parent c5e7605 commit af69972

File tree

3 files changed

+59
-55
lines changed

3 files changed

+59
-55
lines changed

package.json

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,59 @@
11
{
2-
"name": "github-bot",
3-
"description": "Github bot",
4-
"version": "0.0.1",
5-
"main": "src/app.js",
6-
"scripts": {},
7-
"repository": {
8-
"type": "git",
9-
"url": "git+https://github.com/xuexb/github-bot.git"
2+
"name": "github-bot",
3+
"description": "Github bot",
4+
"version": "0.0.1",
5+
"main": "src/app.js",
6+
"scripts": {},
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/xuexb/github-bot.git"
10+
},
11+
"author": "xuexb <[email protected]>",
12+
"license": "MIT",
13+
"bugs": {
14+
"url": "https://github.com/xuexb/github-bot/issues"
15+
},
16+
"homepage": "https://github.com/xuexb/github-bot#readme",
17+
"dependencies": {
18+
"cryptiles": "3.1.2",
19+
"crypto": "^1.0.1",
20+
"dotenv": "^4.0.0",
21+
"github": "^11.0.0",
22+
"koa": "^2.3.0",
23+
"koa-bodyparser": "^4.2.0",
24+
"require-dir": "^0.3.2",
25+
"string-template": "^1.0.0"
26+
},
27+
"engines": {
28+
"node": ">= 4"
29+
},
30+
"config": {
31+
"ghooks": {
32+
"commit-msg": "validate-commit-msg"
1033
},
11-
"author": "xuexb <[email protected]>",
12-
"license": "MIT",
13-
"bugs": {
14-
"url": "https://github.com/xuexb/github-bot/issues"
34+
"validate-commit-msg": {
35+
"types": [
36+
"feat",
37+
"fix",
38+
"docs",
39+
"style",
40+
"test",
41+
"chore",
42+
"revert",
43+
"close"
44+
]
1545
},
16-
"homepage": "https://github.com/xuexb/github-bot#readme",
17-
"dependencies": {
18-
"cryptiles": "3.1.2",
19-
"crypto": "^1.0.1",
20-
"dotenv": "^4.0.0",
21-
"github": "^11.0.0",
22-
"koa": "^2.3.0",
23-
"koa-bodyparser": "^4.2.0",
24-
"require-dir": "^0.3.2",
25-
"string-template": "^1.0.0"
26-
},
27-
"engines": {
28-
"node": ">= 4"
29-
},
30-
"config": {
31-
"ghooks": {
32-
"commit-msg": "validate-commit-msg"
33-
},
34-
"validate-commit-msg": {
35-
"types": ["feat", "fix", "docs", "style", "test", "chore", "revert", "close"]
36-
},
37-
"github-bot": {
38-
"lableToAuthor": {
39-
"bug": "xuexb",
40-
"enhancement": "xuexb",
41-
"question": "xuexb"
42-
}
43-
}
44-
},
45-
"os": ["darwin", "linux"],
46-
"devDependencies": {
47-
"ghooks": "^2.0.0",
48-
"validate-commit-msg": "^2.14.0"
46+
"github-bot": {
47+
"lableToAuthor": {
48+
"bug": "xuexb",
49+
"enhancement": "xuexb",
50+
"question": "xuexb"
51+
}
4952
}
53+
},
54+
"devDependencies": {
55+
"ghooks": "^2.0.0",
56+
"git-pull-or-clone": "^1.1.0",
57+
"validate-commit-msg": "^2.14.0"
58+
}
5059
}

src/modules/releases/autoReleaseNote.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = on => {
7575
body: body.join('\n')
7676
});
7777
}
78-
});
78+
}).catch(err => console.error(err));
7979
});
8080
});
8181
}

src/utils.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const fs = require('fs');
99
const crypto = require('crypto');
1010
const {fixedTimeComparison} = require('cryptiles');
1111
const {execSync, exec} = require('child_process');
12+
const gitPullOrClone = require('git-pull-or-clone');
1213

1314
const utils = {
1415
mentioned(body) {
@@ -85,22 +86,16 @@ const utils = {
8586
*
8687
* @return {Promise}
8788
*/
88-
updateRepo({repo}) {
89+
updateRepo({url, repo}) {
8990
const repoDir = path.resolve(__dirname, '../github/', repo);
9091

91-
if (!utils.isDirectory(repoDir)) {
92-
throw new Error(`${repoDir} 不是github目录!`);
93-
}
94-
9592
return new Promise((resolve, reject) => {
96-
exec(`cd ${repoDir} && git pull`, err => {
93+
gitPullOrClone(url, repoDir, err => {
9794
if (err) {
9895
return reject(err);
9996
}
10097

101-
setTimeout(() => {
102-
resolve(repoDir);
103-
}, 1000);
98+
resolve(repoDir);
10499
});
105100
});
106101
},

0 commit comments

Comments
 (0)