diff --git a/scripts/upload-weapp.js b/scripts/upload-weapp.js index 31f0587..297fadf 100644 --- a/scripts/upload-weapp.js +++ b/scripts/upload-weapp.js @@ -57,10 +57,10 @@ function writeManifest(manifest) { function analyzeCommitTypes(gitLog) { const commits = gitLog.split('\n').filter(line => line.trim()) const types = { - major: 0, // 破坏性变更 - minor: 0, // 新增功能 - patch: 0, // 修复bug - other: 0 // 其他类型 + major: 0, // 破坏性变更 + minor: 0, // 新增功能 + patch: 0, // 修复bug + 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 '' } }