Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pre-commit hook config #42

Closed
wants to merge 4 commits into from
Closed

Conversation

Thulium-Drake
Copy link

Hi there,

I added a config file for pre-commit (https://pre-commit.com) to allow users to automatically sign their code when making commits.

I had to make a small edit (of which I'm not sure if it can break anything), if GPG_TTY is already set and -p is not provided to not change it.

@Thulium-Drake
Copy link
Author

Thulium-Drake commented May 24, 2023

From what I've tested so far, the workflow is:

  1. Configure the pre-commit
  2. Sign your code manually for the first time and add it to the first commit
  3. Run the pre-commit hook, which will sign the code and then complain about files that are modified
  4. Review the changes (the updated manifest)
  5. Run the same commit command again (the editor for making a commit message will open after the hooks have run)

There's still one issue I need to resolve, the first invocation of the hook fails, but the second time 'just works (TM)'. I'm not yet sure why

EDIT: That's working as designed: pre-commit/pre-commit#532

@@ -332,6 +332,8 @@ def gpg_sign(self):
elif "ANSIBLE_SIGN_GPG_PASSPHRASE" in os.environ:
self.logger.debug("Taking GPG key passphrase from ANSIBLE_SIGN_GPG_PASSPHRASE env var")
passphrase = os.environ["ANSIBLE_SIGN_GPG_PASSPHRASE"]
elif "GPG_TTY" in os.environ:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please pull this out into a separate PR?

@Thulium-Drake
Copy link
Author

Continue in #44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants