From 728d882ed007b3c8b785018874a0eb06e1143b66 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Wed, 20 Apr 2022 09:50:19 -0400 Subject: [PATCH] add timestamp docs and examples --- docs/parsers/git_log.md | 51 ++++++++++++++++++++++++++++++++++++----- jc/parsers/git_log.py | 51 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 90 insertions(+), 12 deletions(-) diff --git a/docs/parsers/git_log.md b/docs/parsers/git_log.md index 8de65d86..b4e5a656 100644 --- a/docs/parsers/git_log.md +++ b/docs/parsers/git_log.md @@ -43,8 +43,8 @@ Schema: "author": string, "author_email": string, "date": string, - "epoch": integer, - "epoch_utc": integer, + "epoch": integer, [0] + "epoch_utc": integer, [1] "commit_by": string, "commit_by_email": string, "commit_by_date": string, @@ -60,13 +60,52 @@ Schema: } ] + [0] naive timestamp if "date" field is parsable, else null + [1] timezone aware timestamp availabe for UTC, else null + Examples: - $ git-log | jc --git-log -p - [] + $ git log | jc --git-log -p + [ + { + "commit": "b53e42aca623181aa9bc72194e6eeef1e9a3a237", + "author": "Kelly Brazil", + "author_email": "kellyjonbrazil@gmail.com", + "date": "Wed Apr 20 09:44:42 2022 -0400", + "message": "add calculated timestamp", + "epoch": 1650462282, + "epoch_utc": null + }, + { + "commit": "477329ce5b8f5c2a8e4384ba3f59289fc18c957d", + "author": "Kelly Brazil", + "author_email": "kellyjonbrazil@gmail.com", + "date": "Wed Apr 20 08:26:26 2022 -0400", + "message": "add linefeed to version text", + "epoch": 1650457586, + "epoch_utc": null + }, + ... + ] - $ git-log | jc --git-log -p -r - [] + + $ git log | jc --git-log -p -r + [ + { + "commit": "b53e42aca623181aa9bc72194e6eeef1e9a3a237", + "author": "Kelly Brazil", + "author_email": "kellyjonbrazil@gmail.com", + "date": "Wed Apr 20 09:44:42 2022 -0400", + "message": "add calculated timestamp" + }, + { + "commit": "477329ce5b8f5c2a8e4384ba3f59289fc18c957d", + "author": "Kelly Brazil", + "author_email": "kellyjonbrazil@gmail.com", + "date": "Wed Apr 20 08:26:26 2022 -0400", + "message": "add linefeed to version text" + } + ] diff --git a/jc/parsers/git_log.py b/jc/parsers/git_log.py index ff59bc09..44c10776 100644 --- a/jc/parsers/git_log.py +++ b/jc/parsers/git_log.py @@ -38,8 +38,8 @@ Schema: "author": string, "author_email": string, "date": string, - "epoch": integer, - "epoch_utc": integer, + "epoch": integer, [0] + "epoch_utc": integer, [1] "commit_by": string, "commit_by_email": string, "commit_by_date": string, @@ -55,13 +55,52 @@ Schema: } ] + [0] naive timestamp if "date" field is parsable, else null + [1] timezone aware timestamp availabe for UTC, else null + Examples: - $ git-log | jc --git-log -p - [] + $ git log | jc --git-log -p + [ + { + "commit": "b53e42aca623181aa9bc72194e6eeef1e9a3a237", + "author": "Kelly Brazil", + "author_email": "kellyjonbrazil@gmail.com", + "date": "Wed Apr 20 09:44:42 2022 -0400", + "message": "add calculated timestamp", + "epoch": 1650462282, + "epoch_utc": null + }, + { + "commit": "477329ce5b8f5c2a8e4384ba3f59289fc18c957d", + "author": "Kelly Brazil", + "author_email": "kellyjonbrazil@gmail.com", + "date": "Wed Apr 20 08:26:26 2022 -0400", + "message": "add linefeed to version text", + "epoch": 1650457586, + "epoch_utc": null + }, + ... + ] - $ git-log | jc --git-log -p -r - [] + + $ git log | jc --git-log -p -r + [ + { + "commit": "b53e42aca623181aa9bc72194e6eeef1e9a3a237", + "author": "Kelly Brazil", + "author_email": "kellyjonbrazil@gmail.com", + "date": "Wed Apr 20 09:44:42 2022 -0400", + "message": "add calculated timestamp" + }, + { + "commit": "477329ce5b8f5c2a8e4384ba3f59289fc18c957d", + "author": "Kelly Brazil", + "author_email": "kellyjonbrazil@gmail.com", + "date": "Wed Apr 20 08:26:26 2022 -0400", + "message": "add linefeed to version text" + } + ] """ import re from typing import List, Dict