# HG changeset patch # User Tony Tung > # Date 1517965464 28800 # Node ID aae2d15de6afe7c2a4a2b6128432523931952600 # Parent 327d12aeb5601901941eca6fb098dabdd873d1c6 git_handler: store gpgsig header to maintain commit coherence diff -r 327d12aeb560 -r aae2d15de6af hggit/git_handler.py --- a/hggit/git_handler.py Tue Feb 20 16:21:38 2018 -0800 +++ b/hggit/git_handler.py Tue Feb 06 17:04:24 2018 -0800 @@ -596,6 +596,8 @@ if 'encoding' in extra: commit.encoding = extra['encoding'] + if 'gpgsig' in extra: + commit.gpgsig = extra['gpgsig'] for obj, nodeid in exporter.update_changeset(ctx): if obj.id not in self.git.object_store: @@ -1028,6 +1030,8 @@ if commit.encoding: extra['encoding'] = commit.encoding + if commit.gpgsig: + extra['gpgsig'] = commit.gpgsig if octopus: extra['hg-git'] = 'octopus-done' diff -r 327d12aeb560 -r aae2d15de6af tests/test-git-gpg.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-git-gpg.t Tue Feb 06 17:04:24 2018 -0800 @@ -0,0 +1,74 @@ +#require gpg + +Load commonly used test logic + $ . "$TESTDIR/testutil" + + $ export GNUPGHOME="$(mktemp -d)" + $ cp -R "$TESTDIR"/gpg/* "$GNUPGHOME" + +Start gpg-agent, which is required by GnuPG v2 + +#if gpg21 + $ gpg-connect-agent -q --subst /serverpid '/echo ${get serverpid}' /bye \ + > >> $DAEMON_PIDS +#endif + +and migrate secret keys + +#if gpg2 + $ gpg --no-permission-warning --no-secmem-warning --list-secret-keys \ + > > /dev/null 2>&1 +#endif + + $ alias gpg='gpg --no-permission-warning --no-secmem-warning --no-auto-check-trustdb' + +Set up two identical git repos. + + $ mkdir gitrepo + $ cd gitrepo + $ git init + Initialized empty Git repository in $TESTTMP/gitrepo/.git/ + $ touch a + $ git add a + $ git commit -m "initial commit" + [master (root-commit) *] initial commit (glob) + 1 file changed, 0 insertions(+), 0 deletions(-) + create mode 100644 a + $ cd .. + $ git clone gitrepo gitrepo2 + Cloning into 'gitrepo2'... + done. + +Add a signed commit to the first clone. + + $ cd gitrepo + $ git checkout -b signed + Switched to a new branch 'signed' + $ touch b + $ git add b + $ git commit -m "message" -Shgtest + [signed *] message (glob) + 1 file changed, 0 insertions(+), 0 deletions(-) + create mode 100644 b + $ cd .. + +Hg clone it + + $ hg clone gitrepo hgrepo + importing git objects into hg + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + + $ cd hgrepo + $ hg push ../gitrepo2 -B signed + pushing to ../gitrepo2 + searching for changes + adding objects + added 1 commits with 1 trees and 0 blobs + $ cd .. + +Verify the commit + + $ cd gitrepo2 + $ git show --show-signature signed | grep "Good signature from" + gpg: Good signature from "hgtest" [ultimate]