git_curate 1.1.0 → 1.2.0.beta3

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: 6aa1d8d2c88d0f8d13be7d60fe85d74eaeaf9dbb86e45405936fd00fc72dc538
4
- data.tar.gz: f6e4249ab9a8dae3d505102785c6c946703486cbf730f67d0b120bd038b182ce
3
+ metadata.gz: f3fc938706457be386083c9441a7c50bebfe7b2cab57171f776b73d3e2aec5e3
4
+ data.tar.gz: e7bdcb5b6d3569f50e0666ff00b096b7dc3d5be346abf1a3f069504196e34cde
5
5
  SHA512:
6
- metadata.gz: f5f0452a0548356888aa03caec3638a8ea28d15bff2aca56fb18ff29908c00d13d7cc0df4e9c7ed1a76ef9f5fb20227a33b52f5a2e27c0fdf939eeba025e3005
7
- data.tar.gz: 992422984592b999295f4d4ec09af8f97b5d0b02e3ee506506393344e88ad947344d5e09152780fe5969ee2dd8ee3caa28c291c6ad57c4ba7e462814a1349dbe
6
+ metadata.gz: f1ddd5f0da864679502d13b0e9ab6053abbe9bcbdc5555795da041ce0ffcc8b66af40d9811f0dffe21bdc7d00baa0f042aa5e27b2b3ba4af25c3474197b5ec5a
7
+ data.tar.gz: a57fcb5ea45588673fdfdbee07fc6de2cd384d64323bed105ee4af363109aaad3b4807ec846bc070ec48ce221b5249f6ddcdf3b2812cc95758c2ada9282fe309
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  **/.*.swp
11
11
  coverage
12
+ play.rb
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4.9
4
- - 2.5.8
5
- - 2.6.6
6
- - 2.7.1
3
+ - 2.4.10
4
+ - 2.5.9
5
+ - 2.6.7
6
+ - 2.7.3
7
+ - 3.0.1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ### v1.2.0.beta, v1.2.0.beta2, v1.2.0.beta3
4
+
5
+ * Fix for issue #16: "undefined method upstream" error on MacOS 15.7
6
+ * Add rugged library
7
+
8
+ ### v1.1.2
9
+
10
+ * Dependency version upgrades
11
+ * Include Ruby v3 in automated tests
12
+
13
+ ### v1.1.1
14
+
15
+ * Dependency version upgrades
16
+
3
17
  ### v1.1.0
4
18
 
5
19
  #### Change that may be breaking for an obscure use case
data/README.md CHANGED
@@ -77,8 +77,7 @@ To run the test suite, run `bundle exec rake spec`. For a list of other Rake tas
77
77
 
78
78
  ## License
79
79
 
80
- The gem is available as open source under the terms of the [MIT
81
- License](http://opensource.org/licenses/MIT).
80
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
82
81
 
83
82
  [Gem Version]: https://rubygems.org/gems/git_curate
84
83
  [Build Status]: https://travis-ci.org/matt-harvey/git_curate
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0.beta3
data/git_curate.gemspec CHANGED
@@ -29,8 +29,9 @@ 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 "tabulo", "2.5.0"
33
- spec.add_runtime_dependency "tty-screen", "0.7.1"
32
+ spec.add_runtime_dependency "rugged", "1.1.0"
33
+ spec.add_runtime_dependency "tabulo", "2.6.2"
34
+ spec.add_runtime_dependency "tty-screen", "0.8.1"
34
35
 
35
36
  spec.add_development_dependency "bundler"
36
37
  spec.add_development_dependency "coveralls"
data/lib/git_curate.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "git_curate/app"
2
2
  require "git_curate/branch"
3
+ require "git_curate/commit"
3
4
  require "git_curate/cli_parser"
4
5
  require "git_curate/copyright"
5
6
  require "git_curate/exceptions"
@@ -1,6 +1,6 @@
1
- module GitCurate
1
+ require "rugged"
2
2
 
3
- UpstreamInfo = Struct.new(:upstream, :status)
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
- initialize_last_commit_data
48
- @last_commit_date
47
+ last_commit.date
49
48
  end
50
49
 
51
50
  def hash
52
- initialize_last_commit_data
53
- @hash
51
+ last_commit.hash
54
52
  end
55
53
 
56
54
  def last_author
57
- initialize_last_commit_data
58
- @last_author
55
+ last_commit.author
59
56
  end
60
57
 
61
58
  def last_subject
62
- initialize_last_commit_data
63
- @last_subject
59
+ last_commit.subject
64
60
  end
65
61
 
66
62
  # Returns the local branches
67
63
  def self.local
68
- merged_branch_raw_names = Util.command_to_a("git branch --merged").to_set
64
+ toplevel_dir = Util.command_output("git rev-parse --show-toplevel").strip
65
+ repo = Rugged::Repository.new(toplevel_dir)
69
66
 
70
- branch_info.map do |raw_name, info|
71
- new(raw_name, merged: merged_branch_raw_names.include?(raw_name), upstream_info: info)
72
- end
73
- end
67
+ rugged_branches = repo.branches
68
+ repo_head_target = repo.head.target
74
69
 
75
- private
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
- upstream_info = branches_with_remotes[proper_branch_name]
73
+ rugged_branch = rugged_branches[proper_branch_name]
74
+ upstream = rugged_branch.upstream
92
75
  upstream_data =
93
- if upstream_info.upstream
94
- status = upstream_info.status
95
- if status
96
- status.gsub(/^\[/, "").gsub(/\]$/, "").capitalize
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
- info.to_h
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
- # Returns an array with [date, author, subject], each as a string.
122
- def initialize_last_commit_data
123
- return if @last_commit_data
124
-
125
- # For Windows compatibility we need double quotes around the format string, as well as spaces
126
- # between the placeholders.
127
- command = %Q(git log -n1 --date=short --format=format:"%cd %n %h %n %an %n %s" #{proper_name} --)
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
@@ -0,0 +1,5 @@
1
+ module GitCurate
2
+
3
+ Commit = Struct.new(:date, :hash, :author, :subject)
4
+
5
+ end
@@ -1,3 +1,3 @@
1
1
  module GitCurate
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0.beta3"
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.1.0
4
+ version: 1.2.0.beta3
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: 2020-05-13 00:00:00.000000000 Z
11
+ date: 2021-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -24,34 +24,48 @@ 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.5.0
47
+ version: 2.6.2
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.5.0
54
+ version: 2.6.2
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: tty-screen
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - '='
46
60
  - !ruby/object:Gem::Version
47
- version: 0.7.1
61
+ version: 0.8.1
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - '='
53
67
  - !ruby/object:Gem::Version
54
- version: 0.7.1
68
+ version: 0.8.1
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  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
@@ -185,12 +200,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
200
  version: 2.4.9
186
201
  required_rubygems_version: !ruby/object:Gem::Requirement
187
202
  requirements:
188
- - - ">="
203
+ - - ">"
189
204
  - !ruby/object:Gem::Version
190
- version: '0'
205
+ version: 1.3.1
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: []