Class: Dependabot::PullRequestCreator::CommitSigner
- Inherits:
-
Object
- Object
- Dependabot::PullRequestCreator::CommitSigner
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/pull_request_creator/commit_signer.rb
Instance Attribute Summary collapse
-
#author_details ⇒ Object
readonly
Returns the value of attribute author_details.
-
#commit_message ⇒ Object
readonly
Returns the value of attribute commit_message.
-
#parent_sha ⇒ Object
readonly
Returns the value of attribute parent_sha.
-
#signature_key ⇒ Object
readonly
Returns the value of attribute signature_key.
-
#tree_sha ⇒ Object
readonly
Returns the value of attribute tree_sha.
Instance Method Summary collapse
-
#initialize(author_details:, commit_message:, tree_sha:, parent_sha:, signature_key:) ⇒ CommitSigner
constructor
A new instance of CommitSigner.
- #signature ⇒ Object
Constructor Details
#initialize(author_details:, commit_message:, tree_sha:, parent_sha:, signature_key:) ⇒ CommitSigner
Returns a new instance of CommitSigner.
38 39 40 41 42 43 44 45 |
# File 'lib/dependabot/pull_request_creator/commit_signer.rb', line 38 def initialize(author_details:, commit_message:, tree_sha:, parent_sha:, signature_key:) @author_details = @commit_message = @tree_sha = tree_sha @parent_sha = parent_sha @signature_key = signature_key end |
Instance Attribute Details
#author_details ⇒ Object (readonly)
Returns the value of attribute author_details.
15 16 17 |
# File 'lib/dependabot/pull_request_creator/commit_signer.rb', line 15 def @author_details end |
#commit_message ⇒ Object (readonly)
Returns the value of attribute commit_message.
18 19 20 |
# File 'lib/dependabot/pull_request_creator/commit_signer.rb', line 18 def @commit_message end |
#parent_sha ⇒ Object (readonly)
Returns the value of attribute parent_sha.
24 25 26 |
# File 'lib/dependabot/pull_request_creator/commit_signer.rb', line 24 def parent_sha @parent_sha end |
#signature_key ⇒ Object (readonly)
Returns the value of attribute signature_key.
27 28 29 |
# File 'lib/dependabot/pull_request_creator/commit_signer.rb', line 27 def signature_key @signature_key end |
#tree_sha ⇒ Object (readonly)
Returns the value of attribute tree_sha.
21 22 23 |
# File 'lib/dependabot/pull_request_creator/commit_signer.rb', line 21 def tree_sha @tree_sha end |
Instance Method Details
#signature ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/dependabot/pull_request_creator/commit_signer.rb', line 48 def signature begin require "gpgme" rescue LoadError raise LoadError, "Please add `gpgme` to your Gemfile or gemspec " \ "enable commit signatures" end email = [:email] dir = Dir.mktmpdir GPGME::Engine.home_dir = dir GPGME::Key.import(signature_key) crypto = GPGME::Crypto.new(armor: true) opts = { mode: GPGME::SIG_MODE_DETACH, signer: email } crypto.sign(commit_object, opts).to_s rescue Errno::ENOTEMPTY FileUtils.remove_entry(T.must(dir), true) # This appears to be a Ruby bug which occurs very rarely raise if @retrying @retrying = T.let(true, T.nilable(T::Boolean)) retry ensure FileUtils.remove_entry(T.must(dir), true) end |