lib/ninny/commands/pull_request_merge.rb in ninny-0.1.17 vs lib/ninny/commands/pull_request_merge.rb in ninny-0.1.18
- old
+ new
@@ -4,11 +4,11 @@
module Ninny
module Commands
class PullRequestMerge < Ninny::Command
attr_accessor :pull_request_id, :options, :pull_request
- attr_reader :branch_type
+ attr_reader :branch_type, :username
def initialize(pull_request_id, options)
@branch_type = options[:branch_type] || Ninny::Git::STAGING_PREFIX
self.pull_request_id = pull_request_id
self.options = options
@@ -63,11 +63,14 @@
# Public: The content of the comment to post when merged
#
# Returns a String
def comment_body
- "Merged into #{branch_to_merge_into}."
+ user = username || determine_local_user
+ body = "Merged into #{branch_to_merge_into}".dup
+ body << " by #{user}" if user
+ body << '.'
end
# Public: Find the pull request
#
# Returns a Ninny::Repository::PullRequest
@@ -80,9 +83,14 @@
# Public: Find the branch
#
# Returns a String
def branch_to_merge_into
@branch_to_merge_into ||= Ninny.git.latest_branch_for(branch_type)
+ end
+
+ def determine_local_user
+ local_user_name = `git config user.name`.strip
+ local_user_name.empty? ? nil : local_user_name
end
end
end
end