Sha256: c3429bb9b174191dd21157c4ca1bb54382c66614fb4f75979f5698e4783b0f50

Contents?: true

Size: 903 Bytes

Versions: 10

Compression:

Stored size: 903 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

#
# line-authors
#
# List the authors of a single file, optionally limited
# to the specified lines. Outputs one author name for each
# line.
#
# USAGE
#
# line-authors <filename> <start line> <end line>
# line-authors <filename>
#

GIT_COMMAND = case ARGV.length
              when 3
                filename, start_line, end_line = ARGV
                "git blame --line-porcelain -L #{start_line},#{end_line} #{filename}"
              when 1
                filename = ARGV[0]
                "git blame --line-porcelain #{filename}"
              else
                puts 'Usage: line-authors <filename> <start line> <end line>'
                puts '       line-authors <filename>'
                exit 1
              end

puts(`#{GIT_COMMAND}`
   .lines
   .select { |line| line.start_with?('author ') }
   .map { |line| line.split(' ')[1] })

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
quality_report-1.7.0 exe/line-authors
quality_report-1.6.0 exe/line-authors
quality_report-1.5.0 exe/line-authors
quality_report-1.4.0 exe/line-authors
quality_report-1.3.0 exe/line-authors
quality_report-1.2.2 exe/line-authors
quality_report-1.2.1 exe/line-authors
quality_report-1.2.0 exe/line-authors
quality_report-1.1.0 exe/line-authors
quality_report-1.0.0 exe/line-authors