|
|
|
@ -17,12 +17,13 @@ class ForwardMerge
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def find_forward_merge(message_file)
|
|
|
|
|
def find_forward_merges(message_file)
|
|
|
|
|
$log.debug "Searching for for forward merge"
|
|
|
|
|
rev=`git rev-parse -q --verify MERGE_HEAD`.strip
|
|
|
|
|
$log.debug "Found #{rev} from git rev-parse"
|
|
|
|
|
return nil unless rev
|
|
|
|
|
message = File.read(message_file)
|
|
|
|
|
forward_merges = []
|
|
|
|
|
message.each_line do |line|
|
|
|
|
|
$log.debug "Checking #{line} for message"
|
|
|
|
|
match = /^(?:Fixes|Closes) gh-(\d+) in (\d\.\d\.[\dx](?:[\.\-](?:M|RC)\d)?)$/.match(line)
|
|
|
|
@ -30,11 +31,11 @@ def find_forward_merge(message_file)
|
|
|
|
|
issue = match[1]
|
|
|
|
|
milestone = match[2]
|
|
|
|
|
$log.debug "Matched reference to issue #{issue} in milestone #{milestone}"
|
|
|
|
|
return ForwardMerge.new(issue, milestone, message, line)
|
|
|
|
|
forward_merges << ForwardMerge.new(issue, milestone, message, line)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
$log.debug "No match in merge message"
|
|
|
|
|
return nil
|
|
|
|
|
$log.debug "No match in merge message" unless forward_merges
|
|
|
|
|
return forward_merges
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def get_issue(username, password, repository, number)
|
|
|
|
@ -108,8 +109,8 @@ end
|
|
|
|
|
$log.debug "Running forward-merge hook script"
|
|
|
|
|
message_file=ARGV[0]
|
|
|
|
|
|
|
|
|
|
forward_merge = find_forward_merge(message_file)
|
|
|
|
|
exit 0 unless forward_merge
|
|
|
|
|
forward_merges = find_forward_merges(message_file)
|
|
|
|
|
exit 0 unless forward_merges
|
|
|
|
|
|
|
|
|
|
$log.debug "Loading config from ~/.spring-boot/forward_merge.yml"
|
|
|
|
|
config = YAML.load_file(File.join(Dir.home, '.spring-boot', 'forward-merge.yml'))
|
|
|
|
@ -118,15 +119,17 @@ password = config['github']['credentials']['password']
|
|
|
|
|
dry_run = config['dry_run']
|
|
|
|
|
repository = 'spring-projects/spring-boot'
|
|
|
|
|
|
|
|
|
|
existing_issue = get_issue(username, password, repository, forward_merge.issue)
|
|
|
|
|
title = existing_issue['title']
|
|
|
|
|
labels = existing_issue['labels'].map { |label| label['name'] }
|
|
|
|
|
labels << "status: forward-port"
|
|
|
|
|
$log.debug "Processing issue '#{title}'"
|
|
|
|
|
forward_merges.each do |forward_merge|
|
|
|
|
|
existing_issue = get_issue(username, password, repository, forward_merge.issue)
|
|
|
|
|
title = existing_issue['title']
|
|
|
|
|
labels = existing_issue['labels'].map { |label| label['name'] }
|
|
|
|
|
labels << "status: forward-port"
|
|
|
|
|
$log.debug "Processing issue '#{title}'"
|
|
|
|
|
|
|
|
|
|
milestone = find_milestone(username, password, repository, forward_merge.milestone)
|
|
|
|
|
new_issue_number = create_issue(username, password, repository, forward_merge.issue, title, labels, milestone, forward_merge.milestone, dry_run)
|
|
|
|
|
milestone = find_milestone(username, password, repository, forward_merge.milestone)
|
|
|
|
|
new_issue_number = create_issue(username, password, repository, forward_merge.issue, title, labels, milestone, forward_merge.milestone, dry_run)
|
|
|
|
|
|
|
|
|
|
puts "Created gh-#{new_issue_number} for forward port of gh-#{forward_merge.issue} into #{forward_merge.milestone}"
|
|
|
|
|
rewritten_message = forward_merge.message.sub(forward_merge.line, "Closes gh-#{new_issue_number}\n")
|
|
|
|
|
File.write(message_file, rewritten_message)
|
|
|
|
|
puts "Created gh-#{new_issue_number} for forward port of gh-#{forward_merge.issue} into #{forward_merge.milestone}"
|
|
|
|
|
rewritten_message = forward_merge.message.sub(forward_merge.line, "Closes gh-#{new_issue_number}\n")
|
|
|
|
|
File.write(message_file, rewritten_message)
|
|
|
|
|
end
|
|
|
|
|