git-watchtower 1.14.0 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-watchtower",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
4
4
  "description": "Terminal-based Git branch monitor with activity sparklines and optional dev server with live reload",
5
5
  "main": "bin/git-watchtower.js",
6
6
  "bin": {
@@ -198,7 +198,13 @@ async function log(branchName, options = {}) {
198
198
  }
199
199
 
200
200
  /**
201
- * Get commit count by day for sparkline
201
+ * Get commit count by day for sparkline.
202
+ *
203
+ * Buckets commits by local calendar date rather than by dividing a ms
204
+ * difference by 86 400 000, which breaks on DST transitions (a
205
+ * spring-forward day is only 23 h, causing Math.floor(23/24) = 0 and
206
+ * merging yesterday's commits into today's bucket).
207
+ *
202
208
  * @param {string} branchName - Branch name
203
209
  * @param {number} [days=7] - Number of days
204
210
  * @param {string} [cwd] - Working directory
@@ -215,15 +221,23 @@ async function getCommitsByDay(branchName, days = 7, cwd) {
215
221
 
216
222
  if (!stdout) return counts;
217
223
 
224
+ // Build a map from "YYYY-MM-DD" → bucket index. Using setDate()
225
+ // to step backwards is DST-safe because it adjusts the calendar
226
+ // day without relying on a fixed ms offset.
218
227
  const today = new Date();
219
- today.setHours(0, 0, 0, 0);
228
+ const dayBuckets = new Map();
229
+ for (let i = 0; i < days; i++) {
230
+ const d = new Date(today.getFullYear(), today.getMonth(), today.getDate() - i);
231
+ const key = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
232
+ dayBuckets.set(key, days - 1 - i);
233
+ }
220
234
 
221
235
  for (const line of stdout.split('\n').filter(Boolean)) {
222
236
  const commitDate = new Date(line);
223
- commitDate.setHours(0, 0, 0, 0);
224
- const daysDiff = Math.floor((today.getTime() - commitDate.getTime()) / (1000 * 60 * 60 * 24));
225
- if (daysDiff >= 0 && daysDiff < days) {
226
- counts[days - 1 - daysDiff]++;
237
+ const key = `${commitDate.getFullYear()}-${String(commitDate.getMonth() + 1).padStart(2, '0')}-${String(commitDate.getDate()).padStart(2, '0')}`;
238
+ const idx = dayBuckets.get(key);
239
+ if (idx !== undefined) {
240
+ counts[idx]++;
227
241
  }
228
242
  }
229
243
  } catch (error) {