(tmp_commitizen_project)
| 133 | |
| 134 | @pytest.fixture |
| 135 | def tmp_commitizen_project_with_gpg(tmp_commitizen_project): |
| 136 | # create a temporary GPGHOME to store a temporary keyring. |
| 137 | # Home path must be less than 104 characters |
| 138 | gpg_home = tempfile.TemporaryDirectory(suffix="_cz") |
| 139 | old_gnupghome = os.environ.get("GNUPGHOME") |
| 140 | if os.name != "nt": |
| 141 | os.environ["GNUPGHOME"] = gpg_home.name # tempdir = temp keyring |
| 142 | |
| 143 | try: |
| 144 | # create a key (a keyring will be generated within GPUPGHOME) |
| 145 | subprocess.run( |
| 146 | [ |
| 147 | "gpg", |
| 148 | "--batch", |
| 149 | "--yes", |
| 150 | "--debug-quick-random", |
| 151 | "--passphrase", |
| 152 | "", |
| 153 | "--quick-gen-key", |
| 154 | f"{SIGNER} {SIGNER_MAIL}", |
| 155 | ], |
| 156 | check=True, |
| 157 | ) |
| 158 | key_id = _get_gpg_keyid(SIGNER_MAIL) |
| 159 | assert key_id |
| 160 | |
| 161 | # configure git to use gpg signing |
| 162 | cmd.run(["git", "config", "commit.gpgsign", "true"]) |
| 163 | cmd.run(["git", "config", "user.signingkey", key_id]) |
| 164 | |
| 165 | yield tmp_commitizen_project |
| 166 | finally: |
| 167 | if old_gnupghome is not None: |
| 168 | os.environ["GNUPGHOME"] = old_gnupghome |
| 169 | elif "GNUPGHOME" in os.environ and os.name != "nt": |
| 170 | os.environ.pop("GNUPGHOME") |
| 171 | gpg_home.cleanup() |
| 172 | |
| 173 | |
| 174 | @pytest.fixture |
nothing calls this directly
no test coverage detected
searching dependent graphs…