git_curate 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +9 -3
- data/VERSION +1 -1
- data/assets/demo2.gif +0 -0
- data/lib/git_curate/runner.rb +33 -3
- data/lib/git_curate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1c8358c5021c6985ce3e6d701d607a2df341cc4ed2ba20dac43c13912a1fe44
|
4
|
+
data.tar.gz: c30b0e19d28f7ae48e5fb59372da44158940b8b79008c9d2a07f3b3e8d7d6534
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a872d7d0555cab6a4d4df1d33c96cda3cce1952c09cda057816065e81a7af65c033196365ed0207a255c5cf9c0b190cd500376ca8620b9738084b683064e88c
|
7
|
+
data.tar.gz: 8e842c8f27654e625bcc9b895064a49764c6d67fd0c0b340c8ba900bcd6ad0850b66c836158e08fab0f04d03a3cd98b6dba6c38e84472ab7aa6c97c1db80b72c
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -12,9 +12,15 @@ can't always remember which branches I want to keep from the branch names alone;
|
|
12
12
|
one at a time and _then_ running `git branch -D` in a separate step, is painful.
|
13
13
|
|
14
14
|
`git curate` is intended to ease this pain. It steps you through the local branches of a repo one at
|
15
|
-
a time, outputting
|
16
|
-
|
17
|
-
|
15
|
+
a time, outputting the following information about each:
|
16
|
+
|
17
|
+
* Last commit date
|
18
|
+
* Last commit author
|
19
|
+
* Last commit subject
|
20
|
+
* Whether the branch has been merged into the current HEAD
|
21
|
+
* The status of the branch relative to the upstream branch it is tracking (if any)
|
22
|
+
|
23
|
+
You can then select whether to delete or keep each branch as you go.
|
18
24
|
|
19
25
|
## Installation
|
20
26
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/assets/demo2.gif
CHANGED
Binary file
|
data/lib/git_curate/runner.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
module GitCurate
|
2
2
|
|
3
|
+
# Regexes for unpacking the output of `git branch -vv`
|
4
|
+
BRANCH_NAME_REGEX = /\s+/
|
5
|
+
REMOTE_INFO_REGEX = /^[^\s]+\s+[^\s]+\s+\[(.+?)\]/
|
6
|
+
|
3
7
|
class Runner
|
4
8
|
|
5
9
|
def run
|
@@ -10,6 +14,7 @@ module GitCurate
|
|
10
14
|
|
11
15
|
branches = command_to_a("git branch").reject { |b| current_branch?(b) }
|
12
16
|
merged_branches = command_to_a("git branch --merged").reject { |b| current_branch?(b) }.to_set
|
17
|
+
upstreams = upstream_branches
|
13
18
|
|
14
19
|
table = Tabulo::Table.new(branches, vertical_rule_character: " ", intersection_character: " ",
|
15
20
|
horizontal_rule_character: "-", column_padding: 0) do |t|
|
@@ -28,17 +33,21 @@ module GitCurate
|
|
28
33
|
`git log -n1 --format='format:%s' #{branch}`
|
29
34
|
end
|
30
35
|
|
31
|
-
t.add_column("Merged
|
36
|
+
t.add_column("Merged\ninto HEAD?", align_header: :left) do |branch|
|
32
37
|
merged_branches.include?(branch) ? "Merged" : "Not merged"
|
33
38
|
end
|
39
|
+
|
40
|
+
t.add_column("Status vs\nupstream", align_header: :left) do |branch|
|
41
|
+
upstreams.fetch(branch, "No upstream")
|
42
|
+
end
|
34
43
|
end
|
35
44
|
|
36
|
-
table.shrinkwrap!(max_table_width:
|
45
|
+
table.shrinkwrap!(max_table_width: 150)
|
37
46
|
|
38
47
|
branches_to_delete = []
|
39
48
|
|
40
49
|
table.each_with_index do |row, index|
|
41
|
-
case HighLine.ask("#{row}
|
50
|
+
case HighLine.ask("#{row} Delete? [y/n/done/abort/help] ")
|
42
51
|
when "y"
|
43
52
|
branches_to_delete << row.to_h[:branch]
|
44
53
|
when "n"
|
@@ -69,6 +78,27 @@ module GitCurate
|
|
69
78
|
branch =~ /^\s*\*/
|
70
79
|
end
|
71
80
|
|
81
|
+
# Returns a Hash containing, as keys, all local branches that have upstream branches (excluding
|
82
|
+
# the current branch) and, as values, a brief description of each branch's status relative
|
83
|
+
# to its upstream branch (up to date, or ahead/behind)
|
84
|
+
def upstream_branches
|
85
|
+
command_to_a("git branch -vv").map do |line|
|
86
|
+
branch_name = line.split(BRANCH_NAME_REGEX)[0]
|
87
|
+
remote_info = line[REMOTE_INFO_REGEX, 1]
|
88
|
+
if remote_info.nil?
|
89
|
+
nil
|
90
|
+
else
|
91
|
+
comparison_raw = remote_info.split(":")
|
92
|
+
comparison = if comparison_raw.length < 2
|
93
|
+
"Up to date"
|
94
|
+
else
|
95
|
+
comparison_raw[1].strip.capitalize
|
96
|
+
end
|
97
|
+
[branch_name, comparison]
|
98
|
+
end
|
99
|
+
end.compact.to_h
|
100
|
+
end
|
101
|
+
|
72
102
|
def finalize(branches_to_delete)
|
73
103
|
if branches_to_delete.size != 0
|
74
104
|
puts
|
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: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Harvey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|