fix: ganti --after/--before ke --since/--until dengan waktu eksplisit
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -151,12 +151,11 @@ def upload_timesheet(session_id: str, entry: dict, user_id: int) -> int:
|
|||||||
# ── Git ───────────────────────────────────────────────────────────────────────
|
# ── Git ───────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
def get_commits_today(repo_path: str, author: str, today: str) -> list[dict]:
|
def get_commits_today(repo_path: str, author: str, today: str) -> list[dict]:
|
||||||
until = (date.fromisoformat(today) + timedelta(days=1)).isoformat()
|
|
||||||
cmd = [
|
cmd = [
|
||||||
"git", "-C", repo_path, "log",
|
"git", "-C", repo_path, "log",
|
||||||
f"--author={author}",
|
f"--author={author}",
|
||||||
f"--after={today}",
|
f"--since={today} 00:00:00",
|
||||||
f"--before={until}",
|
f"--until={today} 23:59:59",
|
||||||
"--format=%h|%ad|%s",
|
"--format=%h|%ad|%s",
|
||||||
"--date=format:%Y-%m-%d %H:%M",
|
"--date=format:%Y-%m-%d %H:%M",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ def get_commits(repo_path: str, author: str, since: str, until: str) -> list[dic
|
|||||||
"git", "-C", repo_path,
|
"git", "-C", repo_path,
|
||||||
"log",
|
"log",
|
||||||
f"--author={author}",
|
f"--author={author}",
|
||||||
f"--after={since}",
|
f"--since={since} 00:00:00",
|
||||||
f"--before={until}",
|
f"--until={until} 23:59:59",
|
||||||
"--format=%h|%ad|%s",
|
"--format=%h|%ad|%s",
|
||||||
"--date=short",
|
"--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})")
|
parser.add_argument("--until", default=today, help=f"Tanggal akhir YYYY-MM-DD (default: hari ini {today})")
|
||||||
args = parser.parse_args()
|
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"Author : {args.author}")
|
||||||
print(f"Periode: {args.since} s/d {args.until}")
|
print(f"Periode: {args.since} s/d {args.until}")
|
||||||
print("=" * 60)
|
print("=" * 60)
|
||||||
|
|
||||||
grouped = defaultdict(list)
|
grouped = defaultdict(list)
|
||||||
for repo in REPOS:
|
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]
|
repo_name = repo["path"].split("/")[-1]
|
||||||
for c in commits:
|
for c in commits:
|
||||||
grouped[repo["project"]].append({**c, "repo": repo_name})
|
grouped[repo["project"]].append({**c, "repo": repo_name})
|
||||||
|
|||||||
@@ -122,8 +122,8 @@ def get_commits(repo_path: str, author: str, since: str, until: str) -> list[dic
|
|||||||
"git", "-C", repo_path,
|
"git", "-C", repo_path,
|
||||||
"log",
|
"log",
|
||||||
f"--author={author}",
|
f"--author={author}",
|
||||||
f"--after={since}",
|
f"--since={since} 00:00:00",
|
||||||
f"--before={until}",
|
f"--until={until} 23:59:59",
|
||||||
"--format=%h|%ad|%s",
|
"--format=%h|%ad|%s",
|
||||||
"--date=short",
|
"--date=short",
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user