gollum-rugged_adapter 1.1.2 → 2.1.0

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: 3b4b572fd56e0608c76ab7b3536ed18a54211571ded4f37dbfe77e296df17bfe
4
- data.tar.gz: e3f2ab7a9ae0ebe06eaa1983426a9f89f78796e8535cb6373d21499d45914c72
3
+ metadata.gz: 18259a2992e32502c42836d608a0339a0e0f4e5555aca0a36cba02cc2894ffd5
4
+ data.tar.gz: a0f13307e539bfd3cddc2053fc569ac334feec99b86c58ce592569001632be05
5
5
  SHA512:
6
- metadata.gz: 4c481c8741c577b5cf0e0af292745c04fea0a32d96f89ed77ddb54db726c510517e35e134ca80ab3ddba8966618814fb1590c590c89e2f453fdab2447a62acba
7
- data.tar.gz: 8b7cbcc97c857862a2e60ddb9beb7f625d5eb184ca7800189d95400cbe38400511075083f0dbd50bef91bbe21c9f38f1ba1599675d83dbb31fe5e72d2b903545
6
+ metadata.gz: 5e09da620ba3f9cfdecdb85b00e68fef221209896d9a12a297f6d7e956e9d12bdf719ba88a1b2a2375f03ce1b291956fbf0f76e24f656706eaaaeec5f0bae34a
7
+ data.tar.gz: f8b75d0f80ed360fc6bd14a1e0eb2d9c2e258b0b83460caf73cc0ee039a2c7077b2be3c0919182f6c2ded4ccd105b33262943764aa7d953b5bcb9113d64f8f61
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- [![Gem Version](https://badge.fury.io/rb/gollum-rugged_adapter.svg)](http://badge.fury.io/rb/gollum-rugged_adapter)
1
+ [![Gem Version](https://badge.fury.io/rb/gollum-rugged_adapter.svg)](https://badge.fury.io/rb/gollum-rugged_adapter)
2
2
  ![Build Status](https://github.com/gollum/rugged_adapter/actions/workflows/test.yaml/badge.svg)
3
- [![Dependency Status](https://gemnasium.com/gollum/rugged_adapter.svg)](https://gemnasium.com/gollum/rugged_adapter)
3
+ [![Cutting Edge Dependency Status](https://cuttingedge.onrender.com/github/gollum/rugged_adapter/svg 'Cutting Edge Dependency Status')](https://cuttingedge.onrender.com/github/gollum/rugged_adapter/info)
4
4
 
5
5
  ## DESCRIPTION
6
6
 
data/Rakefile CHANGED
@@ -1,4 +1,7 @@
1
1
  require 'rubygems'
2
+ require 'rake'
3
+ require 'date'
4
+ require 'tempfile'
2
5
 
3
6
  task :default => :rspec
4
7
 
@@ -8,6 +11,18 @@ def name
8
11
  "rugged_adapter"
9
12
  end
10
13
 
14
+ def date
15
+ Time.now.strftime("%Y-%m-%d")
16
+ end
17
+
18
+ def latest_changes_file
19
+ 'LATEST_CHANGES.md'
20
+ end
21
+
22
+ def history_file
23
+ 'HISTORY.md'
24
+ end
25
+
11
26
  def version
12
27
  line = File.read("lib/rugged_adapter/version.rb")[/^\s*VERSION\s*=\s*.*/]
13
28
  line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
@@ -72,6 +87,7 @@ task :release => :build do
72
87
  puts "You must be on the master branch to release!"
73
88
  exit!
74
89
  end
90
+ Rake::Task[:changelog].execute
75
91
  sh "git commit --allow-empty -a -m 'Release #{version}'"
76
92
  sh "git pull --rebase origin master"
77
93
  sh "git tag v#{version}"
@@ -123,4 +139,44 @@ task :validate do
123
139
  puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
124
140
  exit!
125
141
  end
142
+ end
143
+
144
+ desc 'Build changlog'
145
+ task :changelog do
146
+ [latest_changes_file, history_file].each do |f|
147
+ unless File.exist?(f)
148
+ puts "#{f} does not exist but is required to build a new release."
149
+ exit!
150
+ end
151
+ end
152
+
153
+ latest_changes = File.open(latest_changes_file)
154
+ version_pattern = "# #{version}"
155
+
156
+ if !`grep "#{version_pattern}" #{history_file}`.empty?
157
+ puts "#{version} is already described in #{history_file}"
158
+ exit!
159
+ end
160
+
161
+ begin
162
+ unless latest_changes.readline.chomp! =~ %r{#{version_pattern}}
163
+ puts "#{latest_changes_file} should begin with '#{version_pattern}'"
164
+ exit!
165
+ end
166
+ rescue EOFError
167
+ puts "#{latest_changes_file} is empty!"
168
+ exit!
169
+ end
170
+
171
+ body = latest_changes.read
172
+ body.scan(/\s*#\s+\d\.\d.*/) do |match|
173
+ puts "#{latest_changes_file} may not contain multiple markdown headers!"
174
+ exit!
175
+ end
176
+
177
+ temp = Tempfile.new
178
+ temp.puts("#{version_pattern} / #{date}\n#{body}\n\n")
179
+ temp.close
180
+ `cat #{history_file} >> #{temp.path}`
181
+ `cat #{temp.path} > #{history_file}`
126
182
  end
@@ -17,6 +17,18 @@ module Gollum
17
17
  DEFAULT_MIME_TYPE = "text/plain"
18
18
  class NoSuchShaFound < StandardError; end
19
19
 
20
+ def self.global_default_branch
21
+ Rugged::Config.global['init.defaultBranch']
22
+ end
23
+
24
+ def self.default_ref_for_repo(repo)
25
+ begin
26
+ repo.head.name
27
+ rescue Rugged::ReferenceError
28
+ self.global_default_branch || 'refs/heads/master'
29
+ end
30
+ end
31
+
20
32
  class Actor
21
33
 
22
34
  attr_accessor :name, :email, :time
@@ -131,6 +143,22 @@ module Gollum
131
143
  @commit.parents.empty? ? nil : Gollum::Git::Commit.new(@commit.parents.first)
132
144
  end
133
145
 
146
+ def note(ref='refs/notes/commits')
147
+ result = @commit.notes(ref)
148
+ result ? result[:message] : nil
149
+ end
150
+
151
+ def note=(msg, actor = nil, ref='refs/notes/commits')
152
+ actor = Gollum::Git::Actor.default_actor if actor.nil?
153
+ @commit.create_note(
154
+ author: actor.to_h,
155
+ committer: actor.to_h,
156
+ message: msg,
157
+ ref: ref,
158
+ force: true
159
+ )
160
+ end
161
+
134
162
  private
135
163
 
136
164
  def build_stats
@@ -168,7 +196,7 @@ module Gollum
168
196
  end
169
197
 
170
198
  def exist?
171
- ::File.exists?(@repo.path)
199
+ ::File.exist?(@repo.path)
172
200
  end
173
201
 
174
202
  def grep(search_terms, options={}, &block)
@@ -239,7 +267,7 @@ module Gollum
239
267
  end
240
268
  end
241
269
 
242
- def log(ref = 'refs/heads/master', path = nil, options = {})
270
+ def log(ref = Gollum::Git.default_ref_for_repo(@repo), path = nil, options = {})
243
271
  default_options = {
244
272
  :limit => options[:max_count] ? options[:max_count] : 10,
245
273
  :offset => options[:skip] ? options[:skip] : 0,
@@ -265,7 +293,7 @@ module Gollum
265
293
  end
266
294
 
267
295
  def ls_files(query, options = {})
268
- ref = options[:ref] || "refs/heads/master"
296
+ ref = options[:ref] || Gollum::Git.default_ref_for_repo(@repo)
269
297
  tree = @repo.lookup(sha_from_ref(ref)).tree
270
298
  tree = @repo.lookup(tree[options[:path]][:oid]) if options[:path]
271
299
  results = []
@@ -459,6 +487,7 @@ module Gollum
459
487
  def initialize(index, repo)
460
488
  @index = index
461
489
  @rugged_repo = repo
490
+ @default_ref = Gollum::Git.default_ref_for_repo(@rugged_repo)
462
491
  @treemap = {}
463
492
  end
464
493
 
@@ -479,7 +508,7 @@ module Gollum
479
508
  @index
480
509
  end
481
510
 
482
- def commit(message, parents = nil, actor = nil, last_tree = nil, head = 'refs/heads/master')
511
+ def commit(message, parents = nil, actor = nil, last_tree = nil, head = @default_ref)
483
512
  commit_options = {}
484
513
  head = "refs/heads/#{head}" unless head =~ /^refs\/heads\//
485
514
  parents = get_parents(parents, head) || []
@@ -597,7 +626,7 @@ module Gollum
597
626
  end
598
627
  end
599
628
 
600
- def commits(start = 'refs/heads/master', max_count = 10, skip = 0)
629
+ def commits(start = Gollum::Git.default_ref_for_repo(@repo), max_count = 10, skip = 0)
601
630
  git.log(start, nil, :max_count => max_count, :skip => skip)
602
631
  end
603
632
 
@@ -618,7 +647,7 @@ module Gollum
618
647
  @repo.diff(sha1, sha2, opts).patch.force_encoding('utf-8')
619
648
  end
620
649
 
621
- def log(commit = 'refs/heads/master', path = nil, options = {})
650
+ def log(commit = Gollum::Git.default_ref_for_repo(@repo), path = nil, options = {})
622
651
  git.log(commit, path, **options)
623
652
  end
624
653
 
@@ -648,6 +677,14 @@ module Gollum
648
677
  @repo.checkout(ref, :strategy => :force) unless @repo.bare?
649
678
  end
650
679
  end
680
+
681
+ # Find the first existing branch in an Array of branch names of the form ['main', ...] and return its String name.
682
+ def find_branch(search_list)
683
+ all_branches = @repo.branches.to_a.map {|b| b.name}
684
+ search_list.find do |branch_name|
685
+ all_branches.include?(branch_name)
686
+ end
687
+ end
651
688
  end
652
689
 
653
690
  class Tree
@@ -1,7 +1,7 @@
1
1
  module Gollum
2
2
  module Lib
3
3
  module Git
4
- VERSION = '1.1.2'
4
+ VERSION = '2.1.0'
5
5
  end
6
6
  end
7
7
  end
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  s.description = %q{Adapter for Gollum to use Rugged (libgit2) at the backend.}
14
14
  s.license = "MIT"
15
15
 
16
- s.add_runtime_dependency 'rugged', '~> 1.1.0'
17
- s.add_runtime_dependency 'mime-types', '~> 1.15'
16
+ s.add_runtime_dependency 'rugged', '~> 1.5'
17
+ s.add_runtime_dependency 'mime-types', '~> 3.4'
18
18
  s.add_development_dependency 'rspec', "3.4.0"
19
19
 
20
20
  s.files = Dir['lib/**/*.rb'] + ["README.md", "Gemfile"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gollum-rugged_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bart Kamphorst, Dawa Ometto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-22 00:00:00.000000000 Z
11
+ date: 2023-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.0
19
+ version: '1.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.0
26
+ version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mime-types
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.15'
33
+ version: '3.4'
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.15'
40
+ version: '3.4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubygems_version: 3.0.3
89
+ rubygems_version: 3.4.6
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: Adapter for Gollum to use Rugged (libgit2) at the backend.