Bug 578227 - Add way to customise merge commits (e.g to disable GPG signing)
Summary: Add way to customise merge commits (e.g to disable GPG signing)
Status: NEW
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 6.0   Edit
Hardware: Macintosh Mac OS X
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-14 21:43 EST by Chad Wilson CLA
Modified: 2022-01-15 05:20 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chad Wilson CLA 2022-01-14 21:43:39 EST
While you can disable commit signing on an individual commit, it doesn't seem there is a way to disable this when using the `MergeCommand`.

newHeadId = git.commit()
  .setReflogComment(refLogMessage.toString())
  .setInsertChangeId(insertChangeId)
  .call()
  .getId();


I'm not sure if there is a precedent for this, or perhaps I am missing something, but it feels like there could be a way to customise the way the merge commits are made, perhaps with a lambda/strategy you can supply, e.g

setCommitStrategy(Function<CommitCommand, CommitCommand> commitStrategy) { }


setCommitStrategy(commit -> commit.setSign(false))

The workaround is to try and set this config at the entire repo level, but that's suboptimal in some circumstances.
Comment 1 Thomas Wolf CLA 2022-01-15 05:20:49 EST
Looks like some API is missing there.

CommitCommand has setSign(), setSigningKey(), setGpgSigner(), setGpgConfig().

MergeCommand would need these, too, and forward the settings to the CommitCommand.

A work-around for the MergeCommand in the current state might be to use setCommit(false) and then commit separately. Not nice, but maybe a valid work-around.

Related, but those should be tracked in separate bugzilla issues:

* RebaseCommand should also be examined. Should it re-sign rebased commits that
  were signed and committed by the current user, if there is a GpgSigner and
  key?
* Same for CherryPickCommand.