Class: Dependabot::PullRequestCreator::CommitSigner
- Inherits:
-
Object
- Object
- Dependabot::PullRequestCreator::CommitSigner
- 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.
14 15 16 17 18 19 20 21 |
# File 'lib/dependabot/pull_request_creator/commit_signer.rb', line 14 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.
11 12 13 |
# File 'lib/dependabot/pull_request_creator/commit_signer.rb', line 11 def @author_details end |
#commit_message ⇒ Object (readonly)
Returns the value of attribute commit_message.
11 12 13 |
# File 'lib/dependabot/pull_request_creator/commit_signer.rb', line 11 def @commit_message end |
#parent_sha ⇒ Object (readonly)
Returns the value of attribute parent_sha.
11 12 13 |
# File 'lib/dependabot/pull_request_creator/commit_signer.rb', line 11 def parent_sha @parent_sha end |
#signature_key ⇒ Object (readonly)
Returns the value of attribute signature_key.
11 12 13 |
# File 'lib/dependabot/pull_request_creator/commit_signer.rb', line 11 def signature_key @signature_key end |
#tree_sha ⇒ Object (readonly)
Returns the value of attribute tree_sha.
11 12 13 |
# File 'lib/dependabot/pull_request_creator/commit_signer.rb', line 11 def tree_sha @tree_sha end |
Instance Method Details
#signature ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dependabot/pull_request_creator/commit_signer.rb', line 23 def signature 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(dir, true) # This appears to be a Ruby bug which occurs very rarely raise if @retrying @retrying = true retry ensure FileUtils.remove_entry(dir, true) end |