Sha256: ce47896e2b94428a83e7f02e12f587f38462dd0b396419bf7f2c587542b2d7d3

Contents?: true

Size: 1.53 KB

Versions: 5

Compression:

Stored size: 1.53 KB

Contents

#!/usr/bin/env ruby

#
# inspiration taken from:
#
# https://github.com/paulirish/git-recent
#

nl = '%0a' # ASCII NEWLINE
delim = '%07' # ASCII BELL

head = '%(if)%(HEAD)%(then)%(end)'     # emoji prefix for current branch
empty = '%(color:black) %(color:reset)' # to make `column` work correctly

pattern, deref = if ARGV.delete('--tags')
                   ['refs/tags', '*']
                 elsif ARGV.delete('--all')
                   'refs/heads refs/remotes'
                 elsif ARGV.delete('--remotes')
                   'refs/remotes'
                 else
                   'refs/heads'
                 end

branch_name = '%(refname:short)'
branch_name = "%(color:yellow)#{branch_name}%(color:reset)"

object_name = '%(objectname:short)'
object_name = "%(color:red)#{object_name}%(color:reset)"

commit_date = "%(#{deref}committerdate:relative)"
commit_date = "%(color:bold green)(#{commit_date})%(color:reset)"

author_name = "%(#{deref}authorname)"
author_name = "%(color:bold blue)#{author_name}%(color:reset)"

commit_subject = '%(contents:subject)'

format = "#{head} #{branch_name}#{delim}"
format = "#{format}#{object_name} #{commit_date} #{author_name}"
format = "#{format}#{nl}#{empty}#{delim}#{commit_subject}"
format = "#{format}#{nl}#{empty}#{delim}" # empty separator line

require 'shellwords'

cmd = <<-"EOCMD"
  git for-each-ref \
  --color=always \
  --sort=-committerdate \
  --format="#{format}" \
  #{pattern} #{ARGV.shelljoin} | column -t -s $'\a' | less --RAW-CONTROL-CHARS
EOCMD

Kernel.exec(cmd)

# That's all Folks!

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
git-branch--stray-2.0.0 exe/git-branch--list--recent
git-branch--stray-1.8.0 exe/git-branch--list--recent
git-branch--stray-1.7.0 exe/git-branch--list--recent
git-branch--stray-1.6.0 exe/git-branch--list--recent
git-branch--stray-1.5.0 exe/git-branch--list--recent