@@ -151,20 +151,29 @@ async def get_editor() -> str:
151151 ret = os .environ .get ("GIT_EDITOR" , os .environ .get ("EDITOR" , "nano" ))
152152 return ret
153153
154+ async def get_gpg_sign () -> bool :
155+ # commit-tree (plumbing) ignores commit.gpgSign, so read it and pass -S ourselves.
156+ val = await git_ctx .git_stdout (
157+ "config" , "--type=bool" , "--get" , "commit.gpgSign" , raiseonerror = False
158+ )
159+ return val .strip () == "true"
160+
154161 (
155162 repo_root ,
156163 git_dir ,
157164 actual_version ,
158165 email ,
159166 editor ,
160167 main_exists ,
168+ gpg_sign ,
161169 ) = await asyncio .gather (
162170 git_ctx .git_stdout ("rev-parse" , "--show-toplevel" ),
163171 git_ctx .git_stdout ("rev-parse" , "--path-format=absolute" , "--git-dir" ),
164172 git_ctx .git_stdout ("--version" ),
165173 get_email (),
166174 get_editor (),
167175 git_ctx .is_branch_or_commit (f"{ remote_name } /{ main_branch } " ),
176+ get_gpg_sign (),
168177 )
169178
170179 if git_version :
@@ -184,6 +193,7 @@ async def get_editor() -> str:
184193 git_ctx .email = email .lower ()
185194 git_ctx .author = git_ctx .email .split ("@" )[0 ]
186195 git_ctx .editor = editor
196+ git_ctx .gpg_sign = gpg_sign
187197 if not main_exists :
188198 if main_branch in COMMON_MAIN_BRANCHES :
189199 git_ctx .main_branch = COMMON_MAIN_BRANCHES [1 - COMMON_MAIN_BRANCHES .index (main_branch )]
@@ -225,6 +235,9 @@ class Git:
225235 author : str
226236 editor : str
227237
238+ # Whether to GPG/SSH sign commits revup creates, from git config commit.gpgSign
239+ gpg_sign : bool
240+
228241 def __init__ (
229242 self ,
230243 sh : shell .Shell ,
@@ -239,6 +252,7 @@ def __init__(
239252 self .remote_name = remote_name
240253 self .keep_temp = keep_temp
241254 self .main_branch = main_branch
255+ self .gpg_sign = False
242256 self .base_branch_globs = base_branch_globs .strip ().splitlines ()
243257 self .temp_dir = tempfile .TemporaryDirectory ( # pylint: disable=consider-using-with
244258 prefix = "revup_"
@@ -556,6 +570,8 @@ async def commit_tree(self, commit_info: CommitHeader) -> GitCommitHash:
556570 "-m" ,
557571 commit_info .commit_msg ,
558572 ]
573+ if self .gpg_sign :
574+ commit_tree_args .append ("-S" )
559575 for p in commit_info .parents :
560576 commit_tree_args .extend (["-p" , p ])
561577 ret = await self .git_stdout (* commit_tree_args , env = git_env )
0 commit comments