Created
April 8, 2019 09:06
-
-
Save aderyabin/3a77ccde10136801e696687a2290dd7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_pr_text(input) | |
result = input.split("\n").map do |line| | |
task_regex = /((BACKEND\-[0-9]+)\.)?([\s\w]+)(\(#\d+\))?/ | |
regex = /(#\d+)|((BACKEND\-[0-9]+))/ | |
next unless line.match?(regex) #|| line.match?(merge_commit) | |
if line.match?(task_regex) | |
num = line.match(task_regex)[2] | |
text = line.match(task_regex)[3].to_s.strip | |
ya = "([#{num}](https://tracker.yandex.ru/#{num}))" if num | |
"* #{text} #{ya}" | |
else | |
"* #{line.to_s.strip}" | |
end.strip | |
end.compact.uniq | |
result.join("\n") | |
end | |
puts get_pr_text(ARGF.read) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment