gollum-rugged_adapter 1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/rugged_adapter/git_layer_rugged.rb +29 -8
- data/lib/rugged_adapter/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff65dc7719f5202705485b44d61a70c6a46451393aeeb7243c820c468da85e69
|
4
|
+
data.tar.gz: 336e98811d5cb8c19638f6dd8a85d1c5f17d772f2828cea3230ba109e5aaf695
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67f5126eea74217c669854445059f74b7363e3473950b7cf34632b8652f61ad9b0efff8a2fa5ad9e05ee66c6a09144139a8a56d0e3b44b2f1511948cd11508ba
|
7
|
+
data.tar.gz: ab629d342c8346f067b485450a9d898c9238bdff88d60c96c4dab900da01757d4db0bded4f3fdb28522073e5f340757de6d92320d0a26cac71728d9c98d8c2c1
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/gollum-rugged_adapter.svg)](http://badge.fury.io/rb/gollum-rugged_adapter)
|
2
|
-
|
2
|
+
![Build Status](https://github.com/gollum/rugged_adapter/actions/workflows/test.yaml/badge.svg)
|
3
3
|
[![Dependency Status](https://gemnasium.com/gollum/rugged_adapter.svg)](https://gemnasium.com/gollum/rugged_adapter)
|
4
4
|
|
5
5
|
## DESCRIPTION
|
@@ -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
|
@@ -168,13 +180,13 @@ module Gollum
|
|
168
180
|
end
|
169
181
|
|
170
182
|
def exist?
|
171
|
-
::File.
|
183
|
+
::File.exist?(@repo.path)
|
172
184
|
end
|
173
185
|
|
174
186
|
def grep(search_terms, options={}, &block)
|
175
187
|
ref = options[:ref] ? options[:ref] : "HEAD"
|
176
188
|
tree = @repo.lookup(sha_from_ref(ref)).tree
|
177
|
-
tree = @repo.lookup(tree
|
189
|
+
tree = @repo.lookup(tree.path(options[:path])[:oid]) if options[:path]
|
178
190
|
enc = options.fetch(:encoding, 'utf-8')
|
179
191
|
results = []
|
180
192
|
tree.walk_blobs(:postorder) do |root, entry|
|
@@ -239,7 +251,7 @@ module Gollum
|
|
239
251
|
end
|
240
252
|
end
|
241
253
|
|
242
|
-
def log(ref =
|
254
|
+
def log(ref = Gollum::Git.default_ref_for_repo(@repo), path = nil, options = {})
|
243
255
|
default_options = {
|
244
256
|
:limit => options[:max_count] ? options[:max_count] : 10,
|
245
257
|
:offset => options[:skip] ? options[:skip] : 0,
|
@@ -265,7 +277,7 @@ module Gollum
|
|
265
277
|
end
|
266
278
|
|
267
279
|
def ls_files(query, options = {})
|
268
|
-
ref = options[:ref] ||
|
280
|
+
ref = options[:ref] || Gollum::Git.default_ref_for_repo(@repo)
|
269
281
|
tree = @repo.lookup(sha_from_ref(ref)).tree
|
270
282
|
tree = @repo.lookup(tree[options[:path]][:oid]) if options[:path]
|
271
283
|
results = []
|
@@ -459,6 +471,7 @@ module Gollum
|
|
459
471
|
def initialize(index, repo)
|
460
472
|
@index = index
|
461
473
|
@rugged_repo = repo
|
474
|
+
@default_ref = Gollum::Git.default_ref_for_repo(@rugged_repo)
|
462
475
|
@treemap = {}
|
463
476
|
end
|
464
477
|
|
@@ -479,7 +492,7 @@ module Gollum
|
|
479
492
|
@index
|
480
493
|
end
|
481
494
|
|
482
|
-
def commit(message, parents = nil, actor = nil, last_tree = nil, head =
|
495
|
+
def commit(message, parents = nil, actor = nil, last_tree = nil, head = @default_ref)
|
483
496
|
commit_options = {}
|
484
497
|
head = "refs/heads/#{head}" unless head =~ /^refs\/heads\//
|
485
498
|
parents = get_parents(parents, head) || []
|
@@ -597,7 +610,7 @@ module Gollum
|
|
597
610
|
end
|
598
611
|
end
|
599
612
|
|
600
|
-
def commits(start =
|
613
|
+
def commits(start = Gollum::Git.default_ref_for_repo(@repo), max_count = 10, skip = 0)
|
601
614
|
git.log(start, nil, :max_count => max_count, :skip => skip)
|
602
615
|
end
|
603
616
|
|
@@ -615,10 +628,10 @@ module Gollum
|
|
615
628
|
|
616
629
|
def diff(sha1, sha2, *paths)
|
617
630
|
opts = paths.nil? ? {} : {:paths => paths}
|
618
|
-
@repo.diff(sha1, sha2, opts).patch
|
631
|
+
@repo.diff(sha1, sha2, opts).patch.force_encoding('utf-8')
|
619
632
|
end
|
620
633
|
|
621
|
-
def log(commit =
|
634
|
+
def log(commit = Gollum::Git.default_ref_for_repo(@repo), path = nil, options = {})
|
622
635
|
git.log(commit, path, **options)
|
623
636
|
end
|
624
637
|
|
@@ -648,6 +661,14 @@ module Gollum
|
|
648
661
|
@repo.checkout(ref, :strategy => :force) unless @repo.bare?
|
649
662
|
end
|
650
663
|
end
|
664
|
+
|
665
|
+
# Find the first existing branch in an Array of branch names of the form ['main', ...] and return its String name.
|
666
|
+
def find_branch(search_list)
|
667
|
+
all_branches = @repo.branches.to_a.map {|b| b.name}
|
668
|
+
search_list.find do |branch_name|
|
669
|
+
all_branches.include?(branch_name)
|
670
|
+
end
|
671
|
+
end
|
651
672
|
end
|
652
673
|
|
653
674
|
class Tree
|
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:
|
4
|
+
version: 2.0.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:
|
11
|
+
date: 2022-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|
@@ -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.
|
89
|
+
rubygems_version: 3.0.3
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: Adapter for Gollum to use Rugged (libgit2) at the backend.
|