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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -0
- data/VERSION +1 -1
- data/assets/1920px-Topiary_Ch/303/242teau_de_Hautefort_10.jpg +0 -0
- data/lib/git_curate/branch.rb +29 -9
- data/lib/git_curate/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32a05c73884f0ccb28a0c77fbecce6aa123c866b8de6a519fd1dc02f5ae81475
|
4
|
+
data.tar.gz: fa8f0967a63ceb77a4cd325d47e9306882f1de712d656b63ccb6936386ecbc6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a229f824eabb501d718b0533041c7308536fb939219391544b6cca176e5c278e52a0951d14d897142737226175e1911057c7306b430ca0e8752b2b6c920b8e38
|
7
|
+
data.tar.gz: e9166c2594376faeb422fbb4936d788249b59d5b6af530edd655c5f24d9be566615326337b490fb3185df50e1d1d0753bf8bf86d7bb6e55d0521409f43557520
|
data/CHANGELOG.md
CHANGED
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.
|
1
|
+
1.0.1
|
Binary file
|
data/lib/git_curate/branch.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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 =~
|
85
|
-
tidied_line = (line_is_current_branch ? line.gsub(
|
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 =
|
88
|
-
|
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,
|
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
|
data/lib/git_curate/version.rb
CHANGED
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.
|
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-
|
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
|