Skip to content

Commit

Permalink
style: remove the git clone code
Browse files Browse the repository at this point in the history
  • Loading branch information
xuexb authored and yugasun committed Oct 23, 2017
1 parent 6665e00 commit 4c7faf1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 93 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Github robot

### Release

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

## 规则 - Rules

Expand Down
92 changes: 0 additions & 92 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 4c7faf1

Please sign in to comment.