Skip to content

Commit

Permalink
fix: patch user/email env-vars after ssh-env-update
Browse files Browse the repository at this point in the history
If underlying authtype is SSH, environment block will be re-created,
thus discarding username/email env-vars, which subsequently may lead to
git-repo being in a state where some operations are not available (e.g.
creation of commits or notes).

mv patching of related env-vars until after ssh-env is created to avoid
this.
  • Loading branch information
ccwienk committed Dec 14, 2024
1 parent 782875d commit e7e567f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions gitutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,6 @@ def _authenticated_remote(self):
auth_type = self.git_cfg.auth_type

cmd_env = os.environ.copy()
if (user := self.git_cfg.user_name):
cmd_env['GIT_AUTHOR_NAME'] = user
cmd_env['GIT_COMMITTER_NAME'] = user
if (email := self.git_cfg.user_email):
cmd_env['GIT_AUTHOR_EMAIL'] = email
cmd_env['GIT_COMMITTER_EMAIL'] = email

if auth_type is AuthType.SSH:
url = self.git_cfg.repo_url
cmd_env, tmp_id = _ssh_auth_env(git_cfg=self.git_cfg)
Expand All @@ -163,6 +156,13 @@ def _authenticated_remote(self):
else:
raise NotImplementedError

if (user := self.git_cfg.user_name):
cmd_env['GIT_AUTHOR_NAME'] = user
cmd_env['GIT_COMMITTER_NAME'] = user
if (email := self.git_cfg.user_email):
cmd_env['GIT_AUTHOR_EMAIL'] = email
cmd_env['GIT_COMMITTER_EMAIL'] = email

remote = git.remote.Remote.add(
repo=self.repo,
name=random_str(),
Expand Down

0 comments on commit e7e567f

Please sign in to comment.