git_curate 1.0.0 → 1.0.1

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: 7dc878f7afe05d52530f703159c8148c1e717b448c4464235fc5d98474f2b7d3
4
- data.tar.gz: f7c99506b5e110f4fa8a371f6451be20001eb30f9eaec43b281d36dc0a9ef6e3
3
+ metadata.gz: 32a05c73884f0ccb28a0c77fbecce6aa123c866b8de6a519fd1dc02f5ae81475
4
+ data.tar.gz: fa8f0967a63ceb77a4cd325d47e9306882f1de712d656b63ccb6936386ecbc6d
5
5
  SHA512:
6
- metadata.gz: 1f8218d0dae58c980c9e83037f07d76b78ee0a62936dc42d9643a610b247896d399e3eb820f721c43f490d2d913ae017757893ab7738c6e18a40da51046d03e3
7
- data.tar.gz: 7f298ae39612aa6400113721b4fc4c93ae774bc0478de5973af480520fa48e9f305d896555a25d43c8ebd2847befbb2b2616083b8e4997c352ffdbc0fd45aca0
6
+ metadata.gz: a229f824eabb501d718b0533041c7308536fb939219391544b6cca176e5c278e52a0951d14d897142737226175e1911057c7306b430ca0e8752b2b6c920b8e38
7
+ data.tar.gz: e9166c2594376faeb422fbb4936d788249b59d5b6af530edd655c5f24d9be566615326337b490fb3185df50e1d1d0753bf8bf86d7bb6e55d0521409f43557520
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### v1.0.1
4
+
5
+ * Fix `fatal: bad revision '+'` error on encountering multiple worktrees.
6
+
3
7
  ### v1.0.0
4
8
 
5
9
  * Remove support for Ruby < v2.4.9.
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![Gem Version][GV img]][Gem Version]
4
4
  [![Build Status][BS img]][Build Status]
5
5
  [![Coverage Status][CS img]][Coverage Status]
6
+ [![Awesome][AR img]][Awesome Ruby]
6
7
 
7
8
  <img src="https://raw.githubusercontent.com/matt-harvey/git_curate/master/assets/demo.gif" width="1000" alt="Demo" />
8
9
 
@@ -81,7 +82,9 @@ License](http://opensource.org/licenses/MIT).
81
82
  [Gem Version]: https://rubygems.org/gems/git_curate
82
83
  [Build Status]: https://travis-ci.org/matt-harvey/git_curate
83
84
  [Coverage Status]: https://coveralls.io/github/matt-harvey/git_curate
85
+ [Awesome Ruby]: https://awesome-ruby.com/#-git-tools
84
86
 
85
87
  [GV img]: https://img.shields.io/gem/v/git_curate.svg
86
88
  [BS img]: https://img.shields.io/travis/matt-harvey/git_curate.svg
87
89
  [CS img]: https://img.shields.io/coveralls/matt-harvey/git_curate.svg
90
+ [AR img]: https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -3,12 +3,14 @@ module GitCurate
3
3
  class Branch
4
4
 
5
5
  # Regex for determining whether a "raw" branch name is the name of the current branch
6
- CURRENT_BRANCH_REGEX = /^\*\s+/
6
+ # on this or another worktree.
7
+ CURRENT_BRANCH_REGEX = /^[+*]\s+/
7
8
 
8
9
  # Regexes for unpacking the output of `git branch -vv`
9
10
  BRANCH_NAME_REGEX = /\s+/
10
11
  LEADING_STAR_REGEX = /^\* /
11
- REMOTE_INFO_REGEX = /^[^\s]+\s+[^\s]+\s+\[(.+?)\]/
12
+ LEADING_PLUS_REGEX = /^\+ /
13
+ REMOTE_INFO_REGEX = /^[^\s]+\s+[^\s]+\s+(\(.+\)\s+)?\[(?<remote_info>.+)\]/
12
14
 
13
15
  # Returns the branch name, with "* " prefixed if it's the current branch.
14
16
  attr_reader :raw_name
@@ -22,9 +24,19 @@ module GitCurate
22
24
  @proper_name ||= @raw_name.lstrip.sub(CURRENT_BRANCH_REGEX, '')
23
25
  end
24
26
 
25
- # Returns truthy if and only if this is the currently checked out branch.
27
+ # Returns truthy if and only if this is the currently checked out branch on the current
28
+ # worktree.
29
+ def current_branch_this_worktree?
30
+ @current_branch_this_worktree ||= (@raw_name =~ LEADING_STAR_REGEX)
31
+ end
32
+
33
+ # Returns truthy if and only if this is the currently checked out branch on another worktree.
34
+ def current_branch_other_worktree?
35
+ @current_branch_other_worktree ||= (@raw_name =~ LEADING_PLUS_REGEX)
36
+ end
37
+
26
38
  def current?
27
- @current ||= (@raw_name =~ CURRENT_BRANCH_REGEX)
39
+ current_branch_this_worktree? || current_branch_other_worktree?
28
40
  end
29
41
 
30
42
  # Return truthy if and only if this branch has been merged into the current HEAD.
@@ -81,11 +93,18 @@ module GitCurate
81
93
  # date, or ahead/behind).
82
94
  def self.branch_info
83
95
  Util.command_to_a("git branch -vv").map do |line|
84
- line_is_current_branch = (line =~ LEADING_STAR_REGEX)
85
- tidied_line = (line_is_current_branch ? line.gsub(LEADING_STAR_REGEX, "") : line)
96
+ line_is_current_branch = (line =~ CURRENT_BRANCH_REGEX)
97
+ tidied_line = (line_is_current_branch ? line.gsub(CURRENT_BRANCH_REGEX, "") : line)
86
98
  proper_branch_name = tidied_line.split(BRANCH_NAME_REGEX)[0]
87
- raw_branch_name = (line_is_current_branch ? "* #{proper_branch_name}" : proper_branch_name)
88
- remote_info = tidied_line[REMOTE_INFO_REGEX, 1]
99
+ raw_branch_name =
100
+ if line =~ LEADING_STAR_REGEX
101
+ "* #{proper_branch_name}"
102
+ elsif line =~ LEADING_PLUS_REGEX
103
+ "+ #{proper_branch_name}"
104
+ else
105
+ proper_branch_name
106
+ end
107
+ remote_info = tidied_line[REMOTE_INFO_REGEX, :remote_info]
89
108
  upstream_info =
90
109
  if remote_info.nil?
91
110
  "No upstream"
@@ -101,7 +120,8 @@ module GitCurate
101
120
  Util.command_output("git branch -D #{branches.map(&:proper_name).join(" ")} --")
102
121
  end
103
122
 
104
- # raw_name should start in "* " if the current branch, but should otherwise have not whitespace.
123
+ # raw_name should start in "* " if the current branch on this worktree, "+ " if it's the current
124
+ # branch on another worktree, or otherwise have no whitespace.
105
125
  def initialize(raw_name, merged:, upstream_info:)
106
126
  @raw_name = raw_name
107
127
  @merged = merged
@@ -1,3 +1,3 @@
1
1
  module GitCurate
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_curate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Harvey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-25 00:00:00.000000000 Z
11
+ date: 2020-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -154,6 +154,7 @@ files:
154
154
  - README.md
155
155
  - Rakefile
156
156
  - VERSION
157
+ - assets/1920px-Topiary_Château_de_Hautefort_10.jpg
157
158
  - assets/demo.gif
158
159
  - bin/setup
159
160
  - exe/git-curate