style: remove the git clone code

This commit is contained in:
xuexb 2017-10-22 22:19:02 +08:00 committed by Yuga Sun
parent 6665e00b59
commit 4c7faf15d8
2 changed files with 1 additions and 93 deletions

View File

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

View File

@ -28,98 +28,6 @@ const utils = {
return fixedTimeComparison(signature, request.headers['x-hub-signature'])
},
/**
* 目录是否存在
*
* @param {string} file 路径
*
* @return {boolean}
*/
isDirectory (file) {
try {
return fs.statSync(file).isDirectory()
} catch (e) {
if (e.code !== 'ENOENT') {
throw e
}
return false
}
},
/**
* 获取本地 git 目录的第一个提交主要处理当第一次给项目打标签时不能用2个标签去 ..
*
* @param {string} options.dir git 目录
*
* @return {string}
*/
getFirstCommitHash ({ dir }) {
return execSync(`cd ${dir} && git log --oneline --pretty=format:"%h"`).toString()
.split(/\n+/).slice(-1)[0]
},
/**
* 获取本地 git 目录的日志
*
* @param {Object} options 配置数据
* @param {string} options.dir git 目录
* @param {string} options.before 开始版本号
* @param {string} options.after 结束版本号
* @param {string} options.html_url 预览的html地址 用来拼 hash commit
* @param {boolean} [options.hash=false] 是否携带 commit hash log
*
* @return {Array}
*/
getCommitLog (options) {
const shell = [
'cd {dir}',
options.hash
? 'git log {before}..{after} --no-merges --pretty=format:"- [%h]({html_url}/commit/%H) - %s, by @%aN <<%ae>>"'
: 'git log {before}..{after} --no-merges --pretty=format:"- %s, by @%aN <<%ae>>"'
].join(' && ')
return execSync(format(shell, options)).toString().split(/\n+/)
},
/**
* 更新 github 项目
*
* @param {string} options.repo 项目名
*
* @return {Promise}
*/
updateRepo ({ url, repo }) {
const repoDir = path.resolve(__dirname, '../github/', repo)
return new Promise((resolve, reject) => {
gitPullOrClone(url, repoDir, err => {
if (err) {
return reject(err)
}
resolve(repoDir)
})
})
},
/**
* 获取本地 git 目录的 tag 列表
*
* @param {Object} options 配置
* @param {string} options.dir git 目录
*
* @return {Array}
*/
getTags (options) {
const shell = [
'cd {dir}',
'git describe --tags `git rev-list --tags --abbrev=0` --abbrev=0 | uniq'
].join(' && ')
return execSync(format(shell, options)).toString().split(/\n+/).filter(tag => !!tag)
},
/**
* 获取 package.json 里的 config.github-bot
*