You've already forked template-MP
优化 上传脚本获取当天最新提交日志
This commit is contained in:
@@ -57,10 +57,10 @@ function writeManifest(manifest) {
|
|||||||
function analyzeCommitTypes(gitLog) {
|
function analyzeCommitTypes(gitLog) {
|
||||||
const commits = gitLog.split('\n').filter(line => line.trim())
|
const commits = gitLog.split('\n').filter(line => line.trim())
|
||||||
const types = {
|
const types = {
|
||||||
major: 0, // 破坏性变更
|
major: 0, // 破坏性变更
|
||||||
minor: 0, // 新增功能
|
minor: 0, // 新增功能
|
||||||
patch: 0, // 修复bug
|
patch: 0, // 修复bug
|
||||||
other: 0 // 其他类型
|
other: 0, // 其他类型
|
||||||
}
|
}
|
||||||
|
|
||||||
commits.forEach(commit => {
|
commits.forEach(commit => {
|
||||||
@@ -129,21 +129,23 @@ function incrementVersionCode(code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取最新的git提交日志
|
* 获取当天最新的git提交日志
|
||||||
* @param {number} count - 获取最近几条提交,默认5条
|
* @param {number} count - 获取当天最近几条提交,默认3条
|
||||||
* @returns {string} - git日志字符串
|
* @returns {string} - git日志字符串
|
||||||
*/
|
*/
|
||||||
function getGitLog(count = 2) {
|
function getGitLog(count = 3) {
|
||||||
try {
|
try {
|
||||||
// 获取最近N条提交的简短日志,使用相对时间
|
// 获取当天最近N条提交的简短日志
|
||||||
const log = execSync(`git log -${count} --pretty=format:"%s"`, {
|
const log = execSync(`git log --since="today" -${count} --pretty=format:"%s"`, {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
cwd: CONFIG.projectPath,
|
cwd: CONFIG.projectPath,
|
||||||
})
|
})
|
||||||
return log.trim()
|
const trimmedLog = log.trim()
|
||||||
|
// 如果当天没有提交,返回空字符串
|
||||||
|
return trimmedLog || ''
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('获取git日志失败:', error.message)
|
console.warn('获取git日志失败:', error.message)
|
||||||
return '自动化上传'
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user