diff --git a/eden/scm/edenscm/ext/ghstack/__init__.py b/eden/scm/edenscm/ext/ghstack/__init__.py index df06dea582..7b2fa1e43b 100644 --- a/eden/scm/edenscm/ext/ghstack/__init__.py +++ b/eden/scm/edenscm/ext/ghstack/__init__.py @@ -262,6 +262,7 @@ query UsernameQuery { user_name, user_email = gituser.get_identity_or_raise(ui) sh = ghstack.sapling_shell.SaplingShell( conf=conf, + ui=ui, git_dir=git_dir, user_name=user_name, user_email=user_email, diff --git a/eden/scm/ghstack/sapling_shell.py b/eden/scm/ghstack/sapling_shell.py index 74ce57a162..2153b06a5a 100644 --- a/eden/scm/ghstack/sapling_shell.py +++ b/eden/scm/ghstack/sapling_shell.py @@ -3,6 +3,7 @@ import logging import os from typing import Any, Dict, Optional, List +from edenscm import gpg import ghstack import ghstack.config from ghstack.ghs_types import GitCommitHash @@ -14,6 +15,7 @@ class SaplingShell(ghstack.shell.Shell): def __init__(self, *, conf: ghstack.config.Config, + ui = None, # Sapling ui object. git_dir: str, user_name: str, user_email: str, @@ -32,6 +34,7 @@ class SaplingShell(ghstack.shell.Shell): """ super().__init__(quiet=quiet, cwd=cwd, testing=testing) self.conf = conf + self.ui = ui self.git_dir = git_dir self.user_name = user_name self.user_email = user_email @@ -132,7 +135,9 @@ class SaplingShell(ghstack.shell.Shell): """Run `git commit-tree`, adding GPG flags, if appropriate. """ config_flags = ['-c', f'user.name={self.user_name}', '-c', f'user.email={self.user_email}'] - full_args = config_flags + ["commit-tree"] + list(args) + keyid = gpg.get_gpg_keyid(self.ui) + gpg_args = [f'-S{keyid}'] if keyid else [] + full_args = config_flags + ["commit-tree"] + gpg_args + list(args) stdout = self.git(*full_args, **kwargs) if isinstance(stdout, str): return GitCommitHash(stdout) diff --git a/eden/scm/ghstack/shell.py b/eden/scm/ghstack/shell.py index a3e8b52535..184b10cb79 100644 --- a/eden/scm/ghstack/shell.py +++ b/eden/scm/ghstack/shell.py @@ -287,14 +287,10 @@ class Shell(object): ) -> GitCommitHash: """Run `git commit-tree`, adding GPG flags, if appropriate. """ - gpg_args = self.get_gpg_args() + gpg_args = gpg_args_if_necessary(self) full_args = ["commit-tree"] + gpg_args + list(args) return GitCommitHash(self.git(*full_args, **kwargs)) - def get_gpg_args(self) -> List[str]: - """args to include with `git commit` or `git commit-tree` for GPG signing""" - return gpg_args_if_necessary(self) - @overload # noqa: F811 def hg(self, *args: str) -> str: ...