Skip to content

Commit

Permalink
chore: Remove gpg from fix_dot_env_file
Browse files Browse the repository at this point in the history
  • Loading branch information
saattrupdan committed Sep 24, 2024
1 parent 6e05d36 commit 6d408d0
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions src/scripts/fix_dot_env_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
python src/scripts/fix_dot_env_file.py [--non-interactive]
"""

import subprocess
from pathlib import Path
import click

# List of all the environment variables that are desired
DESIRED_ENVIRONMENT_VARIABLES = dict(
GPG_KEY_ID="Enter GPG key ID or leave empty if you do not want to use it. Type "
"`gpg --list-secret-keys --keyid-format=long | grep sec | sed -E "
"'s/.*\/([^ ]+).*/\\1/'` to see your key ID:\n> ", # noqa
GIT_NAME="Enter your full name, to be shown in Git commits:\n> ",
GIT_EMAIL="Enter your email, as registered on your Github account:\n> ",
)
Expand Down Expand Up @@ -62,31 +58,10 @@ def fix_dot_env_file(non_interactive: bool) -> None:
with env_path.open("a") as f:
for env_var in env_vars_missing:
value = ""

if env_var in name_and_email_vars:
value = name_and_email_vars[env_var]
elif env_var == "GPG_KEY_ID":
gpg = subprocess.Popen(
["gpg", "--list-secret-keys", "--keyid-format=long"],
stdout=subprocess.PIPE,
)
grep = subprocess.Popen(
["grep", "sec"], stdin=gpg.stdout, stdout=subprocess.PIPE
)
value = (
subprocess.check_output(
["sed", "-E", "s/.*\\/([^ ]+).*/\\1/"],
stdin=grep.stdout,
)
.decode()
.strip("\n")
)
gpg.wait()
grep.wait()

if value == "" and not non_interactive:
value = input(DESIRED_ENVIRONMENT_VARIABLES[env_var])

f.write(f'{env_var}="{value}"\n')

# Remove the name and email file
Expand Down

0 comments on commit 6d408d0

Please sign in to comment.