The current git hash, if known.
(cls)
| 118 | |
| 119 | @classmethod |
| 120 | def git_hash(cls) -> Optional[str]: |
| 121 | """The current git hash, if known.""" |
| 122 | if cls.__git_hash_attr is None: |
| 123 | import subprocess |
| 124 | |
| 125 | try: |
| 126 | cls.__git_hash_attr = ( |
| 127 | subprocess.check_output( |
| 128 | ["git", "rev-parse", "HEAD"], cwd=cls._root_dir() |
| 129 | ) |
| 130 | .decode("ascii") |
| 131 | .strip() |
| 132 | ) |
| 133 | except subprocess.CalledProcessError: |
| 134 | cls.__git_hash_attr = "" # Non-None but empty. |
| 135 | # A non-None but empty value indicates that we don't know it. |
| 136 | return cls.__git_hash_attr if cls.__git_hash_attr else None |
| 137 | |
| 138 | @classmethod |
| 139 | def string(cls) -> str: |
no test coverage detected