git_curate 1.0.2 → 1.1.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/.travis.yml +0 -1
- data/CHANGELOG.md +20 -0
- data/VERSION +1 -1
- data/lib/git_curate/branch.rb +22 -31
- data/lib/git_curate/runner.rb +10 -7
- 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: 6aa1d8d2c88d0f8d13be7d60fe85d74eaeaf9dbb86e45405936fd00fc72dc538
|
4
|
+
data.tar.gz: f6e4249ab9a8dae3d505102785c6c946703486cbf730f67d0b120bd038b182ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5f0452a0548356888aa03caec3638a8ea28d15bff2aca56fb18ff29908c00d13d7cc0df4e9c7ed1a76ef9f5fb20227a33b52f5a2e27c0fdf939eeba025e3005
|
7
|
+
data.tar.gz: 992422984592b999295f4d4ec09af8f97b5d0b02e3ee506506393344e88ad947344d5e09152780fe5969ee2dd8ee3caa28c291c6ad57c4ba7e462814a1349dbe
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### v1.1.0
|
4
|
+
|
5
|
+
#### Change that may be breaking for an obscure use case
|
6
|
+
|
7
|
+
* Output more helpful message in case there are no deletable branches when `git curate` run without `-l`/`--list` flag.
|
8
|
+
|
9
|
+
This will be a breaking change but only in the unlikely event that the output of `git curate` is being piped
|
10
|
+
through or processed by another program when run in _interactive_ (non-`--list`) mode.
|
11
|
+
|
12
|
+
_New behaviour when there are no deletable branches:_
|
13
|
+
Outputs `There are no local branches that can be deleted.`
|
14
|
+
|
15
|
+
_Old behaviour when there are no deletable branches:_
|
16
|
+
Outputs (irrelevantly and confusingly) the legend of interactive commands, followed by the message
|
17
|
+
`No branches deleted.`
|
18
|
+
|
19
|
+
### v1.0.2
|
20
|
+
|
21
|
+
* Fix incorrect status-vs-upstream when commit subject begins with square-bracket-enclosed string.
|
22
|
+
|
3
23
|
### v1.0.1
|
4
24
|
|
5
25
|
* Fix `fatal: bad revision '+'` error on encountering multiple worktrees.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/lib/git_curate/branch.rb
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
module GitCurate
|
2
2
|
|
3
|
+
UpstreamInfo = Struct.new(:upstream, :status)
|
4
|
+
|
3
5
|
class Branch
|
4
6
|
|
5
7
|
# Regex for determining whether a "raw" branch name is the name of the current branch
|
6
8
|
# on this or another worktree.
|
7
9
|
CURRENT_BRANCH_REGEX = /^[+*]\s+/
|
8
10
|
|
9
|
-
#
|
10
|
-
|
11
|
-
LEADING_STAR_REGEX = /^\* /
|
12
|
-
LEADING_PLUS_REGEX = /^\+ /
|
13
|
-
REMOTE_INFO_REGEX = /^[^\s]+\s+[^\s]+\s+(\(.+\)\s+)?\[(?<remote_info>[^\]]+)\]/
|
14
|
-
|
15
|
-
# Returns the branch name, with "* " prefixed if it's the current branch.
|
11
|
+
# Returns the branch name, with "* " prefixed if it's the current branch on the current
|
12
|
+
# worktree, or "+ " if it's the current branch on another worktree.
|
16
13
|
attr_reader :raw_name
|
17
14
|
|
18
15
|
# Returns a human-friendly string describing the status of the branch relative to the upstream branch
|
@@ -81,35 +78,29 @@ module GitCurate
|
|
81
78
|
# a brief description of each branch's status relative to its upstream branch (up to
|
82
79
|
# date, or ahead/behind).
|
83
80
|
def self.branch_info
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
parts
|
89
|
-
[parts[0], parts[1] || nil]
|
81
|
+
# Double quotes around the format string to ensure Windows compatibility.
|
82
|
+
command = 'git for-each-ref --format="%(refname:short) .. %(upstream:short) .. %(upstream:track)" refs/heads'
|
83
|
+
branches_with_remotes = Util.command_to_a(command).map do |line|
|
84
|
+
parts = line.split("..", -1).map { |s| s.strip! ; s.empty? ? nil : s }
|
85
|
+
[parts[0], UpstreamInfo.new(parts[1], parts[2])]
|
90
86
|
end.to_h
|
91
87
|
|
92
|
-
info = Util.command_to_a(
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
if
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
upstream_info =
|
105
|
-
if branches_with_remotes[proper_branch_name]
|
106
|
-
remote_info = tidied_line[REMOTE_INFO_REGEX, :remote_info]
|
107
|
-
comparison_raw = remote_info.split(":")
|
108
|
-
comparison_raw.length < 2 ? "Up to date" : comparison_raw[1].strip.capitalize
|
88
|
+
info = Util.command_to_a("git branch").map do |line|
|
89
|
+
raw_branch_name = line.strip
|
90
|
+
proper_branch_name = raw_branch_name.gsub(CURRENT_BRANCH_REGEX, "")
|
91
|
+
upstream_info = branches_with_remotes[proper_branch_name]
|
92
|
+
upstream_data =
|
93
|
+
if upstream_info.upstream
|
94
|
+
status = upstream_info.status
|
95
|
+
if status
|
96
|
+
status.gsub(/^\[/, "").gsub(/\]$/, "").capitalize
|
97
|
+
else
|
98
|
+
"Up to date"
|
99
|
+
end
|
109
100
|
else
|
110
101
|
"No upstream"
|
111
102
|
end
|
112
|
-
[raw_branch_name,
|
103
|
+
[raw_branch_name, upstream_data]
|
113
104
|
end
|
114
105
|
|
115
106
|
info.to_h
|
data/lib/git_curate/runner.rb
CHANGED
@@ -26,17 +26,11 @@ module GitCurate
|
|
26
26
|
return EXIT_FAILURE
|
27
27
|
end
|
28
28
|
|
29
|
-
if interactive?
|
30
|
-
puts
|
31
|
-
print_help
|
32
|
-
puts
|
33
|
-
end
|
34
|
-
|
35
29
|
branches = Branch.local
|
36
30
|
branches.reject!(&:current?) if interactive?
|
37
31
|
|
38
32
|
table = Tabulo::Table.new(branches, border: :reduced_ascii, column_padding: 0, align_header: :left) do |t|
|
39
|
-
t.add_column(
|
33
|
+
t.add_column("Branch") { |b| b.displayable_name(pad: !interactive?) }
|
40
34
|
t.add_column("Last commit:#{$/}Date", &:last_commit_date)
|
41
35
|
t.add_column("#{$/}Hash", &:hash)
|
42
36
|
t.add_column("#{$/}Author", &:last_author)
|
@@ -57,6 +51,15 @@ module GitCurate
|
|
57
51
|
return EXIT_SUCCESS
|
58
52
|
end
|
59
53
|
|
54
|
+
if branches.empty?
|
55
|
+
puts "There are no local branches that can be deleted."
|
56
|
+
return EXIT_SUCCESS
|
57
|
+
end
|
58
|
+
|
59
|
+
puts
|
60
|
+
print_help
|
61
|
+
puts
|
62
|
+
|
60
63
|
table.each_with_index do |row, index|
|
61
64
|
case HighLine.ask("#{row} #{prompt}").downcase
|
62
65
|
when "d"
|
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.1.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: 2020-05-
|
11
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|