git_curate 1.1.1 → 1.2.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/.gitignore +1 -0
- data/.travis.yml +5 -4
- data/CHANGELOG.md +13 -0
- data/VERSION +1 -1
- data/git_curate.gemspec +2 -1
- data/lib/git_curate.rb +1 -0
- data/lib/git_curate/branch.rb +39 -47
- data/lib/git_curate/commit.rb +5 -0
- data/lib/git_curate/version.rb +1 -1
- metadata +22 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f8a9157f39dcb50cf904d375b61d8ebf602611ce50cad41b0448db33d746de4
|
4
|
+
data.tar.gz: 7f8465222b4dfc420bd823ca97b936bfdb10c688cb20e030a60f56b94c527096
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9394485c4054ebfaff8fb98b1818efdae552fe3e9724b5f18dafc1064379915c6509031858e5e26cd2b7e2dbd48a9954b15f56dfa0b22334f891a0612368b6ee
|
7
|
+
data.tar.gz: af7835213e93526f5774f61287dbf6051dae5e50fa2f7bb1496683013ed4901dea8db358cdacb11a7e1fe672ca968c64959bd3223d5da6ec66c42d7f4535ad88
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### v1.2.0
|
4
|
+
|
5
|
+
* Fix issue #16: "undefined method 'upstream'" error on MacOS 15.7
|
6
|
+
* Use [rugged](https://github.com/libgit2/rugged) library to get various branch information,
|
7
|
+
decreasing reliance of parsing `git` CLI output, and increasing robustness of the application
|
8
|
+
across platforms.
|
9
|
+
* Dependency version upgrades
|
10
|
+
|
11
|
+
### v1.1.2
|
12
|
+
|
13
|
+
* Dependency version upgrades
|
14
|
+
* Include Ruby v3 in automated tests
|
15
|
+
|
3
16
|
### v1.1.1
|
4
17
|
|
5
18
|
* Dependency version upgrades
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/git_curate.gemspec
CHANGED
@@ -29,7 +29,8 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
31
|
spec.add_runtime_dependency "highline", "2.0.3"
|
32
|
-
spec.add_runtime_dependency "
|
32
|
+
spec.add_runtime_dependency "rugged", "1.1.0"
|
33
|
+
spec.add_runtime_dependency "tabulo", "2.6.3"
|
33
34
|
spec.add_runtime_dependency "tty-screen", "0.8.1"
|
34
35
|
|
35
36
|
spec.add_development_dependency "bundler"
|
data/lib/git_curate.rb
CHANGED
data/lib/git_curate/branch.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
require "rugged"
|
2
2
|
|
3
|
-
|
3
|
+
module GitCurate
|
4
4
|
|
5
5
|
class Branch
|
6
6
|
|
@@ -44,68 +44,63 @@ module GitCurate
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def last_commit_date
|
47
|
-
|
48
|
-
@last_commit_date
|
47
|
+
last_commit.date
|
49
48
|
end
|
50
49
|
|
51
50
|
def hash
|
52
|
-
|
53
|
-
@hash
|
51
|
+
last_commit.hash
|
54
52
|
end
|
55
53
|
|
56
54
|
def last_author
|
57
|
-
|
58
|
-
@last_author
|
55
|
+
last_commit.author
|
59
56
|
end
|
60
57
|
|
61
58
|
def last_subject
|
62
|
-
|
63
|
-
@last_subject
|
59
|
+
last_commit.subject
|
64
60
|
end
|
65
61
|
|
66
62
|
# Returns the local branches
|
67
63
|
def self.local
|
68
|
-
|
64
|
+
toplevel_dir = Util.command_output("git rev-parse --show-toplevel").strip
|
65
|
+
repo = Rugged::Repository.new(toplevel_dir)
|
69
66
|
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
67
|
+
rugged_branches = repo.branches
|
68
|
+
repo_head_target = repo.head.target
|
74
69
|
|
75
|
-
|
76
|
-
|
77
|
-
# Returns a Hash containing, as keys, the raw names of all local branches and, as values,
|
78
|
-
# a brief description of each branch's status relative to its upstream branch (up to
|
79
|
-
# date, or ahead/behind).
|
80
|
-
def self.branch_info
|
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])]
|
86
|
-
end.to_h
|
87
|
-
|
88
|
-
info = Util.command_to_a("git branch").map do |line|
|
70
|
+
Util.command_to_a("git branch").map do |line|
|
89
71
|
raw_branch_name = line.strip
|
90
72
|
proper_branch_name = raw_branch_name.gsub(CURRENT_BRANCH_REGEX, "")
|
91
|
-
|
73
|
+
rugged_branch = rugged_branches[proper_branch_name]
|
74
|
+
upstream = rugged_branch.upstream
|
92
75
|
upstream_data =
|
93
|
-
if
|
94
|
-
|
95
|
-
|
96
|
-
|
76
|
+
if upstream
|
77
|
+
target_id = rugged_branch.target_id
|
78
|
+
ahead, behind = repo.ahead_behind(target_id, upstream.target_id)
|
79
|
+
parts = []
|
80
|
+
parts << "ahead #{ahead}" if ahead != 0
|
81
|
+
parts << "behind #{behind}" if behind != 0
|
82
|
+
if parts.any?
|
83
|
+
parts.join(", ").capitalize
|
97
84
|
else
|
98
85
|
"Up to date"
|
99
86
|
end
|
100
87
|
else
|
101
88
|
"No upstream"
|
102
89
|
end
|
103
|
-
[raw_branch_name, upstream_data]
|
104
|
-
end
|
105
90
|
|
106
|
-
|
91
|
+
target = rugged_branch.resolve.target
|
92
|
+
merged = (repo.merge_base(repo_head_target, target) == target.oid)
|
93
|
+
|
94
|
+
new(
|
95
|
+
raw_branch_name,
|
96
|
+
merged: merged,
|
97
|
+
upstream_info: upstream_data,
|
98
|
+
)
|
99
|
+
end
|
107
100
|
end
|
108
101
|
|
102
|
+
private
|
103
|
+
|
109
104
|
def self.delete_multi(*branches)
|
110
105
|
Util.command_output("git branch -D #{branches.map(&:proper_name).join(" ")} --")
|
111
106
|
end
|
@@ -118,16 +113,13 @@ module GitCurate
|
|
118
113
|
@upstream_info = upstream_info
|
119
114
|
end
|
120
115
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
@last_commit_data = Util.command_to_a(command)
|
129
|
-
|
130
|
-
@last_commit_date, @hash, @last_author, @last_subject = @last_commit_data
|
116
|
+
def last_commit
|
117
|
+
@last_commit ||= begin
|
118
|
+
# For Windows compatibility we need double quotes around the format string, as well as spaces
|
119
|
+
# between the placeholders.
|
120
|
+
command = %Q(git log -n1 --date=short --format=format:"%cd %n %h %n %an %n %s" #{proper_name} --)
|
121
|
+
Commit.new(*Util.command_to_a(command))
|
122
|
+
end
|
131
123
|
end
|
132
124
|
|
133
125
|
end
|
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.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Harvey
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -24,20 +24,34 @@ dependencies:
|
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.0.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rugged
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: tabulo
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - '='
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.6.
|
47
|
+
version: 2.6.3
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - '='
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.6.
|
54
|
+
version: 2.6.3
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: tty-screen
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -163,6 +177,7 @@ files:
|
|
163
177
|
- lib/git_curate/app.rb
|
164
178
|
- lib/git_curate/branch.rb
|
165
179
|
- lib/git_curate/cli_parser.rb
|
180
|
+
- lib/git_curate/commit.rb
|
166
181
|
- lib/git_curate/copyright.rb
|
167
182
|
- lib/git_curate/exceptions.rb
|
168
183
|
- lib/git_curate/runner.rb
|
@@ -174,7 +189,7 @@ licenses:
|
|
174
189
|
metadata:
|
175
190
|
source_code_uri: https://github.com/matt-harvey/git_curate
|
176
191
|
changelog_uri: https://raw.githubusercontent.com/matt-harvey/git_curate/master/CHANGELOG.md
|
177
|
-
post_install_message:
|
192
|
+
post_install_message:
|
178
193
|
rdoc_options: []
|
179
194
|
require_paths:
|
180
195
|
- lib
|
@@ -190,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
205
|
version: '0'
|
191
206
|
requirements: []
|
192
207
|
rubygems_version: 3.1.2
|
193
|
-
signing_key:
|
208
|
+
signing_key:
|
194
209
|
specification_version: 4
|
195
210
|
summary: Simple git branch curation tool
|
196
211
|
test_files: []
|