Skip to content

Instantly share code, notes, and snippets.

@aderyabin
Created April 8, 2019 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aderyabin/3a77ccde10136801e696687a2290dd7e to your computer and use it in GitHub Desktop.
Save aderyabin/3a77ccde10136801e696687a2290dd7e to your computer and use it in GitHub Desktop.
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