From 27c3dccdf3f482c1de3d2fe23a3402dcb78d9212 Mon Sep 17 00:00:00 2001 From: yuantao Date: Thu, 22 Jan 2026 16:39:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E8=8E=B7=E5=8F=96=E5=BD=93=E5=A4=A9=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E6=8F=90=E4=BA=A4=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/upload-weapp.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) 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 '' } }