<commit_before># frozen_string_literal: true

module RubotHandlers::Push
  def self.format_commit(commit)
    sha = "`#{commit['id'][0..6]}` "
    message = commit['message'].lines[0].strip
    author = " [#{commit['author']['username']}]"
    sha + message + author
  end

  def self.handle(payload)
    _, type, *name = payload['ref'].split('/')
    name = name.join('/')
    case type
    when 'heads' # branch
      str = "pushed **#{payload['commits'].length}** commit#{payload['commits'].length == 1 ? '' : 's'} to branch **#{name}**\n"
      str += payload['commits'].map { |e| format_commit(e) }.join("\n")
      str
    end
  end
end<commit_msg>Don't show 'pushed x commits' when zero commits were pushed<commit_after># frozen_string_literal: true

module RubotHandlers::Push
  def self.format_commit(commit)
    sha = "`#{commit['id'][0..6]}` "
    message = commit['message'].lines[0].strip
    author = " [#{commit['author']['username']}]"
    sha + message + author
  end

  def self.handle(payload)
    if payload['commits'].length > 0
      _, type, *name = payload['ref'].split('/')
      name = name.join('/')
      case type
      when 'heads' # branch
        str = "pushed **#{payload['commits'].length}** commit#{payload['commits'].length == 1 ? '' : 's'} to branch **#{name}**\n"
        str += payload['commits'].map { |e| format_commit(e) }.join("\n")
        str
      end
    else
      nil
    end
  end
end
{'fraction_non_alphanumeric': 0.19874476987447698, 'fraction_numerical': 0.006276150627615063, 'mean_word_length': 3.2205882352941178, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4248986', 'n_tokens_mistral': 474, 'n_tokens_neox': 471, 'n_words': 108}