From 2bd1771c2b78d16854773829b99b1ce415e1444e Mon Sep 17 00:00:00 2001 From: "sas.fajri" Date: Thu, 28 May 2026 16:59:59 +0700 Subject: [PATCH] fix: ganti --after/--before ke --since/--until dengan waktu eksplisit Co-Authored-By: Claude Sonnet 4.6 --- daily_timesheet.py | 5 ++--- git_commits.py | 9 +++------ sync_timesheet.py | 4 ++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/daily_timesheet.py b/daily_timesheet.py index e6f7348..d37405b 100755 --- a/daily_timesheet.py +++ b/daily_timesheet.py @@ -151,12 +151,11 @@ def upload_timesheet(session_id: str, entry: dict, user_id: int) -> int: # ── Git ─────────────────────────────────────────────────────────────────────── def get_commits_today(repo_path: str, author: str, today: str) -> list[dict]: - until = (date.fromisoformat(today) + timedelta(days=1)).isoformat() cmd = [ "git", "-C", repo_path, "log", f"--author={author}", - f"--after={today}", - f"--before={until}", + f"--since={today} 00:00:00", + f"--until={today} 23:59:59", "--format=%h|%ad|%s", "--date=format:%Y-%m-%d %H:%M", ] diff --git a/git_commits.py b/git_commits.py index 654d06a..3fcc8cd 100644 --- a/git_commits.py +++ b/git_commits.py @@ -23,8 +23,8 @@ def get_commits(repo_path: str, author: str, since: str, until: str) -> list[dic "git", "-C", repo_path, "log", f"--author={author}", - f"--after={since}", - f"--before={until}", + f"--since={since} 00:00:00", + f"--until={until} 23:59:59", "--format=%h|%ad|%s", "--date=short", ] @@ -53,16 +53,13 @@ def main(): parser.add_argument("--until", default=today, help=f"Tanggal akhir YYYY-MM-DD (default: hari ini {today})") args = parser.parse_args() - # --until perlu +1 hari karena git --before bersifat eksklusif - until_exclusive = (date.fromisoformat(args.until) + timedelta(days=1)).isoformat() - print(f"Author : {args.author}") print(f"Periode: {args.since} s/d {args.until}") print("=" * 60) grouped = defaultdict(list) for repo in REPOS: - commits = get_commits(repo["path"], args.author, args.since, until_exclusive) + commits = get_commits(repo["path"], args.author, args.since, args.until) repo_name = repo["path"].split("/")[-1] for c in commits: grouped[repo["project"]].append({**c, "repo": repo_name}) diff --git a/sync_timesheet.py b/sync_timesheet.py index 39beaec..862c77f 100755 --- a/sync_timesheet.py +++ b/sync_timesheet.py @@ -122,8 +122,8 @@ def get_commits(repo_path: str, author: str, since: str, until: str) -> list[dic "git", "-C", repo_path, "log", f"--author={author}", - f"--after={since}", - f"--before={until}", + f"--since={since} 00:00:00", + f"--until={until} 23:59:59", "--format=%h|%ad|%s", "--date=short", ]