git-branch--stray 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 794726db6368eccf8a09286d03014cdc427ffd3dfc896694af1bee038533ac89
4
- data.tar.gz: 1f4e78547456b0f15b4a03b6abc96c527b76e58048df9426f88943cbfd6b6838
3
+ metadata.gz: 38c9d8e1d58db7616ba67ff142d46181937bbb8c198d3464969fc02074bd5cbb
4
+ data.tar.gz: 25b14cc9e358608d1c1378f2a71a4cbf05bb9e1bf5c58909d41b6d7ac621595a
5
5
  SHA512:
6
- metadata.gz: 97d5f24e9a159cf7bb2e3cfd0bc34a91296e826029eaf98b2265174b990db3a9d187cc88cd83962b79a31dbecaf48309052f88d31bf54d9e8d1cc605084c4c27
7
- data.tar.gz: 58be300de49e6822b9db82c31860970b02b20b79f162129b17a6655daf177654863ed941c04a9840a6ee112c3f76ec72f16162ef607a8fb53eeb975e403547e2
6
+ metadata.gz: f330d5f8a402196f23fe001492b35782b1a701e9a89be21043974df040fdd3148c908877b3ebe229cb33bf7bd45b4b2ade49ee7e7eb84ba4308d41ac7771bab1
7
+ data.tar.gz: 24f6d2ead557c6794e65209ff80b3dc8d1e5b3841f5c87835839ef49b122190e786655b670eb7bd776c54ecf0e726eed1c6c76dccf310fe53ac731eef648e830
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env bash
1
+ #!/usr/bin/env ruby
2
2
 
3
3
  #
4
4
  # inspiration taken from:
@@ -6,50 +6,51 @@
6
6
  # https://github.com/paulirish/git-recent
7
7
  #
8
8
 
9
- NL='%0a' ; # ASCII NEWLINE
10
- DELIM='%07' ; # ASCII BELL
11
-
12
- HEAD="%(if)%(HEAD)%(then)%(end)" ; # emoji prefix for current branch
13
- EMPTY='%(color:black) %(color:reset)' ; # to make `column` work correctly
14
-
15
- case $1 in
16
- --all)
17
- PATTERN='refs/heads refs/remotes' ;
18
- DEREF='' ;
19
- shift ;
20
- ;;
21
- --remotes)
22
- PATTERN='refs/remotes' ;
23
- DEREF='' ;
24
- shift ;
25
- ;;
26
- --tags)
27
- PATTERN='refs/tags' ;
28
- DEREF='*' ;
29
- shift ;
30
- ;;
31
- *)
32
- PATTERN='refs/heads' ;
33
- DEREF='' ;
34
- ;;
35
- esac
36
-
37
- BRANCH_NAME="%(color:yellow)%(refname:short)%(color:reset)" ;
38
- OBJECT_NAME="%(color:red)%(objectname:short)%(color:reset)" ;
39
- COMMIT_DATE="%(color:bold green)(%(${DEREF}committerdate:relative))%(color:reset)" ;
40
- AUTHOR_NAME="%(color:bold blue)%(${DEREF}authorname)%(color:reset)" ;
41
-
42
- COMMIT_SUBJECT='%(contents:subject)' ;
43
-
44
- FORMAT="${HEAD} ${BRANCH_NAME}${DELIM}" ;
45
- FORMAT="${FORMAT}${OBJECT_NAME} ${COMMIT_DATE} ${AUTHOR_NAME}" ;
46
- FORMAT="${FORMAT}${NL}${EMPTY}${DELIM}${COMMIT_SUBJECT}" ;
47
- FORMAT="${FORMAT}${NL}${EMPTY}${DELIM}" ; # empty separator line
48
-
49
- git for-each-ref \
50
- --color=always \
51
- --sort=-committerdate \
52
- --format="${FORMAT}" \
53
- ${PATTERN} "$@" | column -t -s $'\a' | less --RAW-CONTROL-CHARS ;
9
+ nl = '%0a' # ASCII NEWLINE
10
+ delim = '%07' # ASCII BELL
11
+
12
+ head = '%(if)%(HEAD)%(then)%(end)' # emoji prefix for current branch
13
+ empty = '%(color:black) %(color:reset)' # to make `column` work correctly
14
+
15
+ pattern, deref = if ARGV.delete('--tags')
16
+ ['refs/tags', '*']
17
+ elsif ARGV.delete('--all')
18
+ 'refs/heads refs/remotes'
19
+ elsif ARGV.delete('--remotes')
20
+ 'refs/remotes'
21
+ else
22
+ 'refs/heads'
23
+ end
24
+
25
+ branch_name = '%(refname:short)'
26
+ branch_name = "%(color:yellow)#{branch_name}%(color:reset)"
27
+
28
+ object_name = '%(objectname:short)'
29
+ object_name = "%(color:red)#{object_name}%(color:reset)"
30
+
31
+ commit_date = "%(#{deref}committerdate:relative)"
32
+ commit_date = "%(color:bold green)(#{commit_date})%(color:reset)"
33
+
34
+ author_name = "%(#{deref}authorname)"
35
+ author_name = "%(color:bold blue)#{author_name}%(color:reset)"
36
+
37
+ commit_subject = '%(contents:subject)'
38
+
39
+ format = "#{head} #{branch_name}#{delim}"
40
+ format = "#{format}#{object_name} #{commit_date} #{author_name}"
41
+ format = "#{format}#{nl}#{empty}#{delim}#{commit_subject}"
42
+ format = "#{format}#{nl}#{empty}#{delim}" # empty separator line
43
+
44
+ require 'shellwords'
45
+
46
+ cmd = <<-"EOCMD"
47
+ git for-each-ref \
48
+ --color=always \
49
+ --sort=-committerdate \
50
+ --format="#{format}" \
51
+ #{pattern} #{ARGV.shelljoin} | column -t -s $'\a' | less --RAW-CONTROL-CHARS
52
+ EOCMD
53
+
54
+ Kernel.exec(cmd)
54
55
 
55
56
  # That's all Folks!
@@ -2,7 +2,7 @@ module Git
2
2
  module Branch
3
3
  module Stray
4
4
  NAME = 'git-branch--stray'.freeze
5
- VERSION = '1.4.0'.freeze
5
+ VERSION = '1.5.0'.freeze
6
6
 
7
7
  def self.version
8
8
  "#{NAME} v#{VERSION}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-branch--stray
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Vandenberk