Skip to content

Commit

Permalink
scripts: genpinctrl: support non-Git pin data folder
Browse files Browse the repository at this point in the history
This commit adds error checking to the call to `git rev-parse HEAD`,
to ensure genpinctrl does not crash when the pin data folder is not
a Git repository. In such cases, "<unknown commit>" is written to
the pinctrl README file.

Signed-off-by: Mathieu Choplain <[email protected]>
  • Loading branch information
mathieuchopstm committed Aug 2, 2024
1 parent f131715 commit 8227f5a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scripts/genpinctrl/genpinctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pathlib import Path
import re
import shutil
from subprocess import check_output
from subprocess import check_output, STDOUT, CalledProcessError
import xml.etree.ElementTree as ET

from jinja2 import Environment, FileSystemLoader
Expand Down Expand Up @@ -598,8 +598,11 @@ def main(data_path, output):
)

# write readme file
commit_raw = check_output(["git", "rev-parse", "HEAD"], cwd=data_path)
commit = commit_raw.decode("utf-8").strip()
try:
commit_raw = check_output(["git", "rev-parse", "HEAD"], cwd=data_path, stderr=STDOUT)
commit = commit_raw.decode("utf-8").strip()
except CalledProcessError:
commit = "<unknown commit>"
with open(output / "README.rst", "w") as f:
f.write(readme_template.render(commit=commit))

Expand Down

0 comments on commit 8227f5a

Please sign in to comment.