mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge branch '2.4.x'
Closes gh-25588
This commit is contained in:
commit
d283e5957c
@ -17,12 +17,13 @@ class ForwardMerge
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_forward_merge(message_file)
|
def find_forward_merges(message_file)
|
||||||
$log.debug "Searching for for forward merge"
|
$log.debug "Searching for for forward merge"
|
||||||
rev=`git rev-parse -q --verify MERGE_HEAD`.strip
|
rev=`git rev-parse -q --verify MERGE_HEAD`.strip
|
||||||
$log.debug "Found #{rev} from git rev-parse"
|
$log.debug "Found #{rev} from git rev-parse"
|
||||||
return nil unless rev
|
return nil unless rev
|
||||||
message = File.read(message_file)
|
message = File.read(message_file)
|
||||||
|
forward_merges = []
|
||||||
message.each_line do |line|
|
message.each_line do |line|
|
||||||
$log.debug "Checking #{line} for message"
|
$log.debug "Checking #{line} for message"
|
||||||
match = /^(?:Fixes|Closes) gh-(\d+) in (\d\.\d\.[\dx](?:[\.\-](?:M|RC)\d)?)$/.match(line)
|
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]
|
issue = match[1]
|
||||||
milestone = match[2]
|
milestone = match[2]
|
||||||
$log.debug "Matched reference to issue #{issue} in milestone #{milestone}"
|
$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
|
||||||
end
|
end
|
||||||
$log.debug "No match in merge message"
|
$log.debug "No match in merge message" unless forward_merges
|
||||||
return nil
|
return forward_merges
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_issue(username, password, repository, number)
|
def get_issue(username, password, repository, number)
|
||||||
@ -108,8 +109,8 @@ end
|
|||||||
$log.debug "Running forward-merge hook script"
|
$log.debug "Running forward-merge hook script"
|
||||||
message_file=ARGV[0]
|
message_file=ARGV[0]
|
||||||
|
|
||||||
forward_merge = find_forward_merge(message_file)
|
forward_merges = find_forward_merges(message_file)
|
||||||
exit 0 unless forward_merge
|
exit 0 unless forward_merges
|
||||||
|
|
||||||
$log.debug "Loading config from ~/.spring-boot/forward_merge.yml"
|
$log.debug "Loading config from ~/.spring-boot/forward_merge.yml"
|
||||||
config = YAML.load_file(File.join(Dir.home, '.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']
|
dry_run = config['dry_run']
|
||||||
repository = 'spring-projects/spring-boot'
|
repository = 'spring-projects/spring-boot'
|
||||||
|
|
||||||
existing_issue = get_issue(username, password, repository, forward_merge.issue)
|
forward_merges.each do |forward_merge|
|
||||||
title = existing_issue['title']
|
existing_issue = get_issue(username, password, repository, forward_merge.issue)
|
||||||
labels = existing_issue['labels'].map { |label| label['name'] }
|
title = existing_issue['title']
|
||||||
labels << "status: forward-port"
|
labels = existing_issue['labels'].map { |label| label['name'] }
|
||||||
$log.debug "Processing issue '#{title}'"
|
labels << "status: forward-port"
|
||||||
|
$log.debug "Processing issue '#{title}'"
|
||||||
|
|
||||||
milestone = find_milestone(username, password, repository, forward_merge.milestone)
|
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)
|
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}"
|
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")
|
rewritten_message = forward_merge.message.sub(forward_merge.line, "Closes gh-#{new_issue_number}\n")
|
||||||
File.write(message_file, rewritten_message)
|
File.write(message_file, rewritten_message)
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user