Skip to content

Commit 4c7faf1

Browse files
xuexbyugasun
authored andcommitted
style: remove the git clone code
1 parent 6665e00 commit 4c7faf1

2 files changed

Lines changed: 1 addition & 93 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Github robot
2020

2121
### Release
2222

23-
- [x] 当往远程第一次推送新版本号时,自动列出最新版本距离上一版本的 commit log 并发布 release notes ,会把项目 clone 到 `./github/{项目名}/` 去分析 commit log
23+
- [x] 当往远程第一次推送新版本号时,自动列出最新版本距离上一版本的 commit log 并发布 release notes ,由于需要使用两个 tag 去对比,所以项目的第一个 tag 就不处理
2424

2525
## 规则 - Rules
2626

src/utils.js

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -28,98 +28,6 @@ const utils = {
2828
return fixedTimeComparison(signature, request.headers['x-hub-signature'])
2929
},
3030

31-
/**
32-
* 目录是否存在
33-
*
34-
* @param {string} file 路径
35-
*
36-
* @return {boolean}
37-
*/
38-
isDirectory (file) {
39-
try {
40-
return fs.statSync(file).isDirectory()
41-
} catch (e) {
42-
if (e.code !== 'ENOENT') {
43-
throw e
44-
}
45-
46-
return false
47-
}
48-
},
49-
50-
/**
51-
* 获取本地 git 目录的第一个提交,主要处理当第一次给项目打标签时不能用2个标签去 ..
52-
*
53-
* @param {string} options.dir git 目录
54-
*
55-
* @return {string}
56-
*/
57-
getFirstCommitHash ({ dir }) {
58-
return execSync(`cd ${dir} && git log --oneline --pretty=format:"%h"`).toString()
59-
.split(/\n+/).slice(-1)[0]
60-
},
61-
62-
/**
63-
* 获取本地 git 目录的日志
64-
*
65-
* @param {Object} options 配置数据
66-
* @param {string} options.dir git 目录
67-
* @param {string} options.before 开始版本号
68-
* @param {string} options.after 结束版本号
69-
* @param {string} options.html_url 预览的html地址, 用来拼 hash commit
70-
* @param {boolean} [options.hash=false] 是否携带 commit hash log
71-
*
72-
* @return {Array}
73-
*/
74-
getCommitLog (options) {
75-
const shell = [
76-
'cd {dir}',
77-
options.hash
78-
? 'git log {before}..{after} --no-merges --pretty=format:"- [%h]({html_url}/commit/%H) - %s, by @%aN <<%ae>>"'
79-
: 'git log {before}..{after} --no-merges --pretty=format:"- %s, by @%aN <<%ae>>"'
80-
].join(' && ')
81-
82-
return execSync(format(shell, options)).toString().split(/\n+/)
83-
},
84-
85-
/**
86-
* 更新 github 项目
87-
*
88-
* @param {string} options.repo 项目名
89-
*
90-
* @return {Promise}
91-
*/
92-
updateRepo ({ url, repo }) {
93-
const repoDir = path.resolve(__dirname, '../github/', repo)
94-
95-
return new Promise((resolve, reject) => {
96-
gitPullOrClone(url, repoDir, err => {
97-
if (err) {
98-
return reject(err)
99-
}
100-
101-
resolve(repoDir)
102-
})
103-
})
104-
},
105-
106-
/**
107-
* 获取本地 git 目录的 tag 列表
108-
*
109-
* @param {Object} options 配置
110-
* @param {string} options.dir git 目录
111-
*
112-
* @return {Array}
113-
*/
114-
getTags (options) {
115-
const shell = [
116-
'cd {dir}',
117-
'git describe --tags `git rev-list --tags --abbrev=0` --abbrev=0 | uniq'
118-
].join(' && ')
119-
120-
return execSync(format(shell, options)).toString().split(/\n+/).filter(tag => !!tag)
121-
},
122-
12331
/**
12432
* 获取 package.json 里的 config.github-bot
12533
*

0 commit comments

Comments
 (0)