@@ -231,7 +231,7 @@ def changelogs(
231
231
until = config .get ("until" , "" )
232
232
log_options = config .get ("log_options" , "" )
233
233
pathspec = config .get ("pathspec" , "" )
234
- limit = config .get ("limit" , "10" )
234
+ limit = int ( config .get ("limit" , 10 ) )
235
235
236
236
# Original git command:
237
237
# git -c log.showSignature=false log --use-mailmap $_merges --format="%cd" --date=short "${_author}"
@@ -327,28 +327,24 @@ def my_daily_status(config: Dict[str, Union[str, int]]) -> None:
327
327
Returns:
328
328
None
329
329
"""
330
-
331
330
# Grab the config options from our config.py.
332
331
# config.py should give fallbacks for these, but for sanity,
333
332
# lets also provide some defaults just in case.
334
333
merges = config .get ("merges" , "--no-merges" )
335
334
log_options = config .get ("log_options" , "" )
336
335
337
336
print ("My daily status:" )
338
-
339
337
# Equivalent Bash Command:
340
338
# git diff --shortstat '@{0 day ago}' | sort -nr | tr ',' '\n' \
341
339
# | LC_ALL=C awk '{ args[NR] = $0; } END { for (i = 1; i <= NR; ++i) \
342
340
# { printf "\t%s\n", args[i] } }'
343
341
344
342
# Mimic 'git diff --shortstat "@{0 day ago}"'
345
343
diff_cmd = ["git" , "diff" , "--shortstat" , "@{0 day ago}" ]
346
-
347
344
diff_output = run_git_command (diff_cmd )
348
345
if diff_output :
349
346
# Replace commas with newlines
350
347
diff_lines = [line .strip () for line in diff_output .split ("," )]
351
-
352
348
# Print each line prefixed with a tab
353
349
for line in diff_lines :
354
350
print (f"\t { line } " )
@@ -366,6 +362,7 @@ def my_daily_status(config: Dict[str, Union[str, int]]) -> None:
366
362
367
363
# Get the user's name
368
364
# Lets also handle the case if the user's name is not set correctly
365
+
369
366
git_user = run_git_command (["git" , "config" , "user.name" ])
370
367
if not git_user :
371
368
git_user = "unknown"
@@ -374,41 +371,37 @@ def my_daily_status(config: Dict[str, Union[str, int]]) -> None:
374
371
today = datetime .now ().strftime ("%Y-%m-%d" )
375
372
since = f"--since={ today } T00:00:00"
376
373
until = f"--until={ today } T23:59:59"
377
-
374
+
378
375
# Build the final git log command
379
376
log_cmd = [
380
377
"git" ,
381
378
"-c" ,
382
379
"log.showSignature=false" ,
383
380
"log" ,
384
381
"--use-mailmap" ,
385
- "--author" ,
386
- git_user ,
382
+ f"--author={ git_user } " , # Ensure the 'f' prefix is present
387
383
merges ,
388
384
since ,
389
385
until ,
390
386
"--reverse" ,
387
+ "--pretty=%H" , # Output only commit hashes
391
388
log_options ,
392
389
]
393
-
390
+
394
391
# Remove any empty space from the log_cmd
395
392
log_cmd = [arg for arg in log_cmd if arg ]
396
-
397
393
# Execute the git log command
398
394
log_output = run_git_command (log_cmd )
399
395
400
396
# Bash version uses grep to count lines matching the hash pattern
401
- # "commit [a-f0-9]{40}"
402
- # We can use re to mimic this in Python
403
- # TODO: Revisit this. We might be able to do --pretty=format:%H to avoid
404
- # having to use a regex to handle this portion. This could be
405
- # an improvement to feed back to the original project
397
+ # "commit [a-f0-9]{40}". But it's not necessary with %H.
398
+ # TODO: We are be able to do --pretty=format:%H to avoid
399
+ # having to use a regex to handle this portion.
400
+ # Feed back to the original project
406
401
if log_output :
407
- commit_pattern = re .compile (r"^commit [a-f0-9]{40}$" , re .MULTILINE )
408
- commit_count = len (commit_pattern .findall (log_output ))
402
+ commit_count = len (log_output .strip ().splitlines ())
409
403
else :
410
404
commit_count = 0
411
-
412
405
# Print the commit count, prefixed with a tab
413
406
print (f"\t { commit_count } commits" )
414
407
0 commit comments