yefrem

Untitled

Aug 18th, 2025
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require 'rubocop'
  3.  
  4. def prepare_msg(ticket_number, commit_message, path_to_commit_msg)
  5. return if ticket_number.blank?
  6.  
  7. prefix_regexp = Regexp.new("^(\\[#{ticket_number}\\]|fixup!|squash!)")
  8. return if commit_message.match(prefix_regexp)
  9.  
  10. File.write(path_to_commit_msg, "[#{ticket_number}] #{commit_message}")
  11. end
  12.  
  13. path_to_commit_msg = ARGV[0]
  14. init_commit_message = File.read(path_to_commit_msg)
  15. ticket_number = %x(git symbolic-ref --short HEAD | grep -i -o -E '(TZN|TKXEL|CORE|TRA|BACKTES|INTEG|GROWTH)-[0-9]+' | tr '[:lower:]' '[:upper:] | xargs').to_s.chomp
  16.  
  17. prepare_msg(ticket_number, init_commit_message, path_to_commit_msg)
  18.  
  19. exit 0
Advertisement
Add Comment
Please, Sign In to add comment