Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Unbreak GPG signed commits in mojombo/grit
From ece98ab701a181c87dd288f7853ebea18f02ee08 Mon Sep 17 00:00:00 2001
From: Alexander Dormann <alexdo@alexdo.de>
Date: Mon, 25 Mar 2013 16:12:46 +0100
Subject: [PATCH] Strip GPG lines from commit
---
lib/grit/commit.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/grit/commit.rb b/lib/grit/commit.rb
index 403ea33..e3ed375 100644
--- a/lib/grit/commit.rb
+++ b/lib/grit/commit.rb
@@ -137,7 +137,8 @@ module Grit
# - it broke when 'encoding' was introduced - not sure what else might show up
#
def self.list_from_string(repo, text)
- lines = text.split("\n")
+ text_gpgless = text.gsub(/gpgsig -----BEGIN PGP SIGNATURE-----[\n\r](.*[\n\r])*? -----END PGP SIGNATURE-----[\n\r]/, "")
+ lines = text_gpgless.split("\n")
commits = []
--
1.7.10.2 (Apple Git-33)
@kevinoconnor7

This comment has been minimized.

Copy link

kevinoconnor7 commented Mar 28, 2013

As someone who GPG signs his commit, thank you for being awesome.

@gousiosg

This comment has been minimized.

Copy link

gousiosg commented Aug 21, 2013

Thanks for this. You actually don't need to apply a patch or download new gems as you describe in your blog. You can just monkey patch list_from_string like this:

class Grit::Commit
  class << self
    alias_method :original_list_from_string, :list_from_string

    def list_from_string(repo, text)
      text.gsub!(/gpgsig -----BEGIN PGP SIGNATURE-----[\n\r](.*[\n\r])*? -----END PGP SIGNATURE-----[\n\r]/, "")
      original_list_from_string(repo, text)
    end
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.