(repoPath, repoName, date)
| 108 | |
| 109 | // 获取指定日期的提交 |
| 110 | function getCommitsForDate(repoPath, repoName, date) { |
| 111 | try { |
| 112 | const { since, until } = getCommitWindow(date); |
| 113 | |
| 114 | const gitLog = execSync( |
| 115 | `cd ${repoPath} && git log --since="${since}" --until="${until}" --pretty=format:"%h|%s|%an|%ad" --date=format:"%H:%M" --name-only`, |
| 116 | { encoding: 'utf8' } |
| 117 | ).trim(); |
| 118 | |
| 119 | if (!gitLog) { |
| 120 | return []; |
| 121 | } |
| 122 | |
| 123 | const commits = []; |
| 124 | const commitBlocks = gitLog.split('\n\n'); |
| 125 | |
| 126 | commitBlocks.forEach(block => { |
| 127 | const lines = block.trim().split('\n'); |
| 128 | if (lines.length === 0) return; |
| 129 | |
| 130 | const [hash, message, author, time] = lines[0].split('|'); |
| 131 | const changedFiles = lines.slice(1).filter(file => file.trim()); |
| 132 | |
| 133 | // 从文件路径提取插件名 |
| 134 | const detectedPlugins = extractPluginNames(changedFiles, repoName); |
| 135 | |
| 136 | commits.push({ |
| 137 | hash: hash.trim(), |
| 138 | message: message.trim(), |
| 139 | author: author.trim(), |
| 140 | time: time.trim(), |
| 141 | repo: repoName, |
| 142 | changedFiles: changedFiles, |
| 143 | detectedPlugins: detectedPlugins |
| 144 | }); |
| 145 | }); |
| 146 | |
| 147 | return commits; |
| 148 | } catch (error) { |
| 149 | console.warn(`⚠️ 获取 ${repoName} 提交记录失败:`, error.message); |
| 150 | return []; |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | // 从文件路径提取插件名 |
| 155 | function extractPluginNames(changedFiles, repoName) { |
no test coverage detected