git_curate 1.2.0.beta2 → 1.2.1

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: 0d25c82cca61f81731702b5ff45d30a44ed5778304c49a0a250171f268fd8ce9
4
- data.tar.gz: b4ad3c50995bcee65fb57c6455b70b6960cf7ee5309265e70fd95f6a80c666ea
3
+ metadata.gz: 50c509c86ea95a040e7585fe963ddf1dcc393a5119ca88b13f0b80979e8cd228
4
+ data.tar.gz: c5d43923dbd54b153d087680f25e8af9b9428f63fce7c72a6371d9b30a9ae080
5
5
  SHA512:
6
- metadata.gz: 317df38e0f8d54f750544346570961ac09c4d5f03c5b1593c3423d53e461cb8c64b2d1e669453c3bf2f9ade9cd8a1c1336ba2aea4edc3a29b401912b8c374259
7
- data.tar.gz: 6b6f5d5fee3bd0c6b96114afd5fda13ecd6cfc99d1ba5ebeff7fe16de44e5fe74239e530589adcec0423034d25a9918413af45b36771a758236693fb6a77737f
6
+ metadata.gz: c73b1abed7812ef99ca538d6d68946feda57320f0b4ee37885bd083b00ea8e675d6aa0c0a696dff6ffa881fa8fc9d7758c6e4ce73cb0ad4aeea5c9c5435e5b9d
7
+ data.tar.gz: 36c31763289bb4a50de7bb585d32308ffab6593a0116fce702578deddd8f8ea6e3268ae4dbd71d7a97727edf977a4d584e9f042a80ff5b57ec678c0c8b32f3e1
@@ -0,0 +1,56 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Tests
9
+
10
+ on:
11
+ push:
12
+ branches: [master]
13
+ pull_request:
14
+ branches: [master]
15
+
16
+ jobs:
17
+ test:
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ matrix:
21
+ ruby-version: [
22
+ '2.4.10',
23
+ '2.5.9',
24
+ '2.6.10',
25
+ '2.7.6',
26
+ '3.0.4',
27
+ '3.1.2',
28
+ ]
29
+ steps:
30
+ - uses: actions/checkout@v2
31
+ - name: Set up Ruby
32
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
33
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
34
+ uses: ruby/setup-ruby@v1 # Was: uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
35
+ with:
36
+ ruby-version: ${{ matrix.ruby-version }}
37
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
38
+ - name: Run tests
39
+ run: bundle exec rspec
40
+ - name: Report to Coveralls
41
+ uses: coverallsapp/github-action@v1.1.2
42
+ with:
43
+ github-token: ${{ secrets.github_token }}
44
+ flag-name: test-${{ matrix.ruby }}-${{ matrix.gemfile }}
45
+ parallel: true
46
+
47
+ finish:
48
+ needs: test
49
+ runs-on: ubuntu-latest
50
+ steps:
51
+
52
+ - name: Report completion to Coveralls
53
+ uses: coverallsapp/github-action@v1.1.2
54
+ with:
55
+ github-token: ${{ secrets.github_token }}
56
+ parallel-finished: truec
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  **/.*.swp
11
11
  coverage
12
+ play.rb
data/CHANGELOG.md CHANGED
@@ -1,9 +1,18 @@
1
1
  # Changelog
2
2
 
3
- ### v1.2.0.beta, v1.2.0.beta2
3
+ ### v1.2.1
4
4
 
5
- * Fix for issue #16: "undefined method upstream" error on MacOS 15.7
6
- * Add rugged library
5
+ * Dependency version upgrades
6
+ * GitHub actions replaces Travis for CI
7
+ * Better installation instructions around 'rugged' dependency
8
+
9
+ ### v1.2.0
10
+
11
+ * Fix issue #16: "undefined method 'upstream'" error on MacOS 15.7
12
+ * Use [rugged](https://github.com/libgit2/rugged) library to get various branch information,
13
+ decreasing reliance of parsing `git` CLI output, and increasing robustness of the application
14
+ across platforms.
15
+ * Dependency version upgrades
7
16
 
8
17
  ### v1.1.2
9
18
 
data/README.md CHANGED
@@ -40,6 +40,15 @@ gem install git_curate
40
40
 
41
41
  to install the executable.
42
42
 
43
+ Note `git_curate` uses the [rugged](https://github.com/libgit2/rugged) library, which comes with a
44
+ native C extension, `libgit2`. Installation via `gem install git_curate` will trigger this extension
45
+ to be compiled; this may take a few minutes, depending on your machine.
46
+
47
+ If you receive an error like `ERROR: Failed to build gem native extension`, it’s probably because
48
+ your system lacks certain prerequisites needed for building `libgit2`, for example `cmake`. To fix this,
49
+ first follow the [installation instructions for rugged](https://github.com/libgit2/rugged#install); then
50
+ run `gem install git_curate` again.
51
+
43
52
  ## Usage
44
53
 
45
54
  From within a git repo, run:
@@ -80,11 +89,11 @@ To run the test suite, run `bundle exec rake spec`. For a list of other Rake tas
80
89
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
81
90
 
82
91
  [Gem Version]: https://rubygems.org/gems/git_curate
83
- [Build Status]: https://travis-ci.org/matt-harvey/git_curate
92
+ [Build Status]: https://github.com/matt-harvey/git_curate/actions/workflows/tests.yml
84
93
  [Coverage Status]: https://coveralls.io/github/matt-harvey/git_curate
85
94
  [Awesome Ruby]: https://awesome-ruby.com/#-git-tools
86
95
 
87
96
  [GV img]: https://img.shields.io/gem/v/git_curate.svg
88
- [BS img]: https://img.shields.io/travis/matt-harvey/git_curate.svg
97
+ [BS img]: https://github.com/matt-harvey/git_curate/actions/workflows/tests.yml/badge.svg
89
98
  [CS img]: https://img.shields.io/coveralls/matt-harvey/git_curate.svg
90
99
  [AR img]: https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0.beta2
1
+ 1.2.1
data/git_curate.gemspec CHANGED
@@ -29,14 +29,14 @@ 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 "rugged", "1.1.0"
33
- spec.add_runtime_dependency "tabulo", "2.6.2"
32
+ spec.add_runtime_dependency "rugged", "1.4.3"
33
+ spec.add_runtime_dependency "tabulo", "2.8.0"
34
34
  spec.add_runtime_dependency "tty-screen", "0.8.1"
35
35
 
36
36
  spec.add_development_dependency "bundler"
37
- spec.add_development_dependency "coveralls"
38
37
  spec.add_development_dependency "rake", "~> 13.0"
39
38
  spec.add_development_dependency "rake-version", "~> 1.0"
40
39
  spec.add_development_dependency "rspec", "~> 3.9"
41
40
  spec.add_development_dependency "simplecov"
41
+ spec.add_development_dependency "simplecov-lcov"
42
42
  end
@@ -2,12 +2,8 @@ require "rugged"
2
2
 
3
3
  module GitCurate
4
4
 
5
- UpstreamInfo = Struct.new(:upstream, :status)
6
-
7
5
  class Branch
8
6
 
9
- @@repo = Rugged::Repository.new(".")
10
-
11
7
  # Regex for determining whether a "raw" branch name is the name of the current branch
12
8
  # on this or another worktree.
13
9
  CURRENT_BRANCH_REGEX = /^[+*]\s+/
@@ -48,29 +44,28 @@ module GitCurate
48
44
  end
49
45
 
50
46
  def last_commit_date
51
- initialize_last_commit_data
52
- @last_commit_date
47
+ last_commit.date
53
48
  end
54
49
 
55
50
  def hash
56
- initialize_last_commit_data
57
- @hash
51
+ last_commit.hash
58
52
  end
59
53
 
60
54
  def last_author
61
- initialize_last_commit_data
62
- @last_author
55
+ last_commit.author
63
56
  end
64
57
 
65
58
  def last_subject
66
- initialize_last_commit_data
67
- @last_subject
59
+ last_commit.subject
68
60
  end
69
61
 
70
62
  # Returns the local branches
71
63
  def self.local
72
- rugged_branches = @@repo.branches
73
- repo_head_target = @@repo.head.target
64
+ toplevel_dir = Util.command_output("git rev-parse --show-toplevel").strip
65
+ repo = Rugged::Repository.new(toplevel_dir)
66
+
67
+ rugged_branches = repo.branches
68
+ repo_head_target = repo.head.target
74
69
 
75
70
  Util.command_to_a("git branch").map do |line|
76
71
  raw_branch_name = line.strip
@@ -80,7 +75,7 @@ module GitCurate
80
75
  upstream_data =
81
76
  if upstream
82
77
  target_id = rugged_branch.target_id
83
- ahead, behind = @@repo.ahead_behind(target_id, upstream.target_id)
78
+ ahead, behind = repo.ahead_behind(target_id, upstream.target_id)
84
79
  parts = []
85
80
  parts << "ahead #{ahead}" if ahead != 0
86
81
  parts << "behind #{behind}" if behind != 0
@@ -94,7 +89,7 @@ module GitCurate
94
89
  end
95
90
 
96
91
  target = rugged_branch.resolve.target
97
- merged = (@@repo.merge_base(repo_head_target, target) == target.oid)
92
+ merged = (repo.merge_base(repo_head_target, target) == target.oid)
98
93
 
99
94
  new(
100
95
  raw_branch_name,
@@ -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.2.0.beta2"
2
+ VERSION = "1.2.1"
3
3
  end
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"
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.2.0.beta2
4
+ version: 1.2.1
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: 2021-05-29 00:00:00.000000000 Z
11
+ date: 2022-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 1.1.0
33
+ version: 1.4.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 1.1.0
40
+ version: 1.4.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: tabulo
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 2.6.2
47
+ version: 2.8.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 2.6.2
54
+ version: 2.8.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: tty-screen
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: coveralls
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: rake
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +136,20 @@ dependencies:
150
136
  - - ">="
151
137
  - !ruby/object:Gem::Version
152
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov-lcov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
153
  description: Step through local git branches from the command line, keeping or deleting
154
154
  each.
155
155
  email:
@@ -159,9 +159,9 @@ executables:
159
159
  extensions: []
160
160
  extra_rdoc_files: []
161
161
  files:
162
+ - ".github/workflows/tests.yml"
162
163
  - ".gitignore"
163
164
  - ".rspec"
164
- - ".travis.yml"
165
165
  - CHANGELOG.md
166
166
  - Gemfile
167
167
  - LICENSE.txt
@@ -177,19 +177,19 @@ files:
177
177
  - lib/git_curate/app.rb
178
178
  - lib/git_curate/branch.rb
179
179
  - lib/git_curate/cli_parser.rb
180
+ - lib/git_curate/commit.rb
180
181
  - lib/git_curate/copyright.rb
181
182
  - lib/git_curate/exceptions.rb
182
183
  - lib/git_curate/runner.rb
183
184
  - lib/git_curate/util.rb
184
185
  - lib/git_curate/version.rb
185
- - play.rb
186
186
  homepage: https://github.com/matt-harvey/git_curate
187
187
  licenses:
188
188
  - MIT
189
189
  metadata:
190
190
  source_code_uri: https://github.com/matt-harvey/git_curate
191
191
  changelog_uri: https://raw.githubusercontent.com/matt-harvey/git_curate/master/CHANGELOG.md
192
- post_install_message:
192
+ post_install_message:
193
193
  rdoc_options: []
194
194
  require_paths:
195
195
  - lib
@@ -200,12 +200,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
200
  version: 2.4.9
201
201
  required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  requirements:
203
- - - ">"
203
+ - - ">="
204
204
  - !ruby/object:Gem::Version
205
- version: 1.3.1
205
+ version: '0'
206
206
  requirements: []
207
- rubygems_version: 3.1.2
208
- signing_key:
207
+ rubygems_version: 3.2.3
208
+ signing_key:
209
209
  specification_version: 4
210
210
  summary: Simple git branch curation tool
211
211
  test_files: []
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4.10
4
- - 2.5.8
5
- - 2.6.6
6
- - 2.7.2
7
- - 3.0.0
data/play.rb DELETED
@@ -1,31 +0,0 @@
1
- require "rugged"
2
-
3
- repo = Rugged::Repository.new(".")
4
-
5
- current_branch_name = repo.head.name.sub(/^refs\/heads\//, '')
6
-
7
- repo.branches.each_name(:local) do |branch_name|
8
- branch_reference = repo.references["refs/heads/#{branch_name}"]
9
- branch = repo.branches[branch_name]
10
- is_current = current_branch_name == branch_name
11
- target_id = branch.target_id
12
- top_commit = branch_reference.log.first
13
- commit = repo.lookup(target_id)
14
-
15
- target = branch.resolve.target
16
- merged = repo.merge_base(repo.head.target, target) == target.oid
17
-
18
- puts "Branch: #{is_current ? '* ' + branch_name : branch_name}"
19
- puts "date: #{commit.time}"
20
- puts "hash: #{target_id}"
21
- puts "author: #{top_commit[:committer][:name]}"
22
- puts "subject: #{commit.message.split($/, -1)[0]}"
23
- if branch.upstream
24
- puts "upstream: #{branch.upstream.name}"
25
- ahead, behind = repo.ahead_behind(target_id, branch.upstream.target_id)
26
- puts "ahead: #{ahead}"
27
- puts "behind: #{behind}"
28
- end
29
- puts "merged: #{merged ? 'Merged' : 'Not merged'}"
30
- puts "*****************"
31
- end