Skip to content

Commit 1c22863

Browse files
committed
fix(log): use local time for log cleanup date comparison
Fix timezone issue in cleanupOldLogs: use new Date(year, month-1, day) instead of new Date(dateString) to ensure consistent local time comparison.
1 parent 35db772 commit 1c22863

2 files changed

Lines changed: 62 additions & 4 deletions

File tree

.github/workflows/auto-assign.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Auto Assign PR
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
branches:
7+
- main
8+
9+
permissions:
10+
pull-requests: write
11+
12+
jobs:
13+
assign:
14+
name: Auto Assign & Request Review
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Add assignee to PR
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
await github.rest.issues.addAssignees({
23+
owner: context.repo.owner,
24+
repo: context.repo.repo,
25+
issue_number: context.payload.pull_request.number,
26+
assignees: ['MikotoZero']
27+
});
28+
console.log(`✅ Assigned MikotoZero to PR #${context.payload.pull_request.number}`);
29+
30+
# 请求 Copilot 进行代码审查
31+
# 注意:需要 PR 创建者有 Copilot Pro 订阅才能生效
32+
- name: Request Copilot Code Review
33+
uses: actions/github-script@v7
34+
continue-on-error: true
35+
with:
36+
script: |
37+
try {
38+
// 使用 GitHub API 请求 Copilot review
39+
// 这个 API 是 GitHub Copilot code review 的公开接口
40+
await github.request('POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers', {
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
pull_number: context.payload.pull_request.number,
44+
reviewers: ['copilot-pull-request-reviewer[bot]']
45+
});
46+
console.log(`✅ Requested Copilot review for PR #${context.payload.pull_request.number}`);
47+
} catch (error) {
48+
console.log(`⚠️ Could not request Copilot review: ${error.message}`);
49+
console.log('This may require the PR author to have Copilot Pro subscription.');
50+
}

src/core/utils/logWriter.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,18 @@ export class LogWriter {
228228
for (const file of files) {
229229
const match = file.match(pattern);
230230
if (match) {
231-
const fileDate = new Date(match[1]);
232-
if (fileDate < cutoffDate) {
233-
await fs.promises.unlink(path.join(this.config.logDir, file));
234-
process.stderr.write(`[LogWriter] Deleted old log: ${file}\n`);
231+
// 使用本地时间创建日期,避免时区问题
232+
// new Date("YYYY-MM-DD") 会被解释为 UTC 时间,而 cutoffDate 是本地时间
233+
const [yearStr, monthStr, dayStr] = match[1].split('-');
234+
const year = Number(yearStr);
235+
const month = Number(monthStr);
236+
const day = Number(dayStr);
237+
if (!Number.isNaN(year) && !Number.isNaN(month) && !Number.isNaN(day)) {
238+
const fileDate = new Date(year, month - 1, day); // 本地时间
239+
if (fileDate < cutoffDate) {
240+
await fs.promises.unlink(path.join(this.config.logDir, file));
241+
process.stderr.write(`[LogWriter] Deleted old log: ${file}\n`);
242+
}
235243
}
236244
}
237245
}

0 commit comments

Comments
 (0)