]> granicus.if.org Git - graphviz/commitdiff
remove redundant datetime computation in version script
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 19 Nov 2022 17:39:00 +0000 (09:39 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 24 Nov 2022 18:50:23 +0000 (10:50 -0800)
Instead of parsing the date Git gives us and then reformatting it into a new
form, we can just ask Git to give it to us in the format we want.

gen_version.py

index e277186f78b4566ff548ad5ae93a074bb08fc20a..9a5ad3e59919b66aa0f570c6ab854139fd22a81b 100644 (file)
@@ -22,7 +22,6 @@ Entry version   Entry collection          Output
 """
 
 import argparse
-from datetime import datetime
 import os
 from pathlib import Path
 import re
@@ -135,21 +134,18 @@ else:
 if not patch_version.isnumeric() or args.date_format:
   os.environ["TZ"] = "UTC"
   try:
-    committer_date = datetime.strptime(
-        subprocess.check_output(
+    committer_date = subprocess.check_output(
             [
                 "git",
                 "log",
                 "-n",
                 "1",
                 "--format=%cd",
-                "--date=format-local:%Y-%m-%d %H:%M:%S"
+               f"--date=format-local:{date_format}"
             ],
             cwd=os.path.abspath(os.path.dirname(__file__)),
             universal_newlines=True,
-        ).strip(),
-        "%Y-%m-%d %H:%M:%S",
-    ).strftime(date_format)
+        ).strip()
   except (subprocess.CalledProcessError, FileNotFoundError):
     sys.stderr.write("Warning: build not started in a Git clone, or Git is not "
                      "installed: setting version date to 0.\n")