branchy 0.4.0 → 0.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
  SHA1:
3
- metadata.gz: ed3b4d0d61cab54a877cdfe1189243e29fca9706
4
- data.tar.gz: 7e8edebf165f2de57c3965613e42edcc72a91f2a
3
+ metadata.gz: 708d94cf9a7312815cb9f02ffbdfa66677d8aab1
4
+ data.tar.gz: f19c689a44f991826d6ed41d1b228a752ec87b77
5
5
  SHA512:
6
- metadata.gz: fc1b13b2dfc60097984d7b62a55d553ed2fb8caf4d51f8568f845fa37a31117482f1d06f6e311869e9bd3f11e4639d4397a88a00f8b72922165fbc750a3038db
7
- data.tar.gz: 604d96dd3f37bbd1191f6cbff430f0cf6e9436aaa2491bd6b8201bbdb65a4ad8aa782cdf5ab3f4b64aae4984be46b1096ed74625a7be204b2b1dcab66f41a9ce
6
+ metadata.gz: e96c3cdee3afdebe75cdcbd26ffdaafd2d7b53178553be3e533bad1c2cde6943a890a554a638174494ce4641343d281d20e671f1fd9a0f08d600030876f2ff4e
7
+ data.tar.gz: 9b2869343c0ae5af0129a88b11fce89c8fef35cd450114458a581dbc6898707aeb4652ab37dfeea040b647154120ec11b6ad52ba5c5fb88ecc4344c13eea6dc1
@@ -7,8 +7,7 @@ module Branchy
7
7
 
8
8
  # Returns the git branch or tag name
9
9
  def self.branch
10
- digest = exec_or_raise('git rev-parse HEAD')
11
- exec_or_raise("git name-rev --name-only #{digest}").sub(/^tags\//, '').sub(/\^0$/, '')
10
+ branch_name || tag_name
12
11
  end
13
12
 
14
13
  # Returns true if it's the master/trunk/mainline branch.
@@ -30,6 +29,19 @@ module Branchy
30
29
  def self.disable!
31
30
  exec_or_raise("git config --bool branch.#{branch}.database false")
32
31
  end
32
+
33
+ private
34
+
35
+ def self.branch_name
36
+ name = exec_or_raise('git rev-parse --abbrev-ref HEAD')
37
+ name == 'HEAD'.freeze ? nil : name
38
+ end
39
+
40
+ def self.tag_name
41
+ log = exec_or_raise("git reflog show --decorate -1")
42
+ match = log.match(/, tag: ([^,]+), /)
43
+ match ? match.captures[0] : nil
44
+ end
33
45
  end
34
46
  end
35
47
  end
@@ -1,4 +1,4 @@
1
1
  module Branchy
2
2
  # The gem version
3
- VERSION = '0.4.0'.freeze
3
+ VERSION = '0.5.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: branchy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Coleman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-10 00:00:00.000000000 Z
12
+ date: 2015-08-14 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Use a different database for each of your branches!
15
15
  email: jordan@jordanhollinger.com