优化 上传脚本获取当天最新提交日志

This commit is contained in:
yuantao
2026-01-22 16:39:35 +08:00
parent b19663aed4
commit 27c3dccdf3

View File

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