rdavila-rugged 0.24.0b13
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 +7 -0
- data/LICENSE +21 -0
- data/README.md +619 -0
- data/ext/rugged/extconf.rb +105 -0
- data/ext/rugged/rugged.c +527 -0
- data/ext/rugged/rugged.h +185 -0
- data/ext/rugged/rugged_backend.c +34 -0
- data/ext/rugged/rugged_blame.c +292 -0
- data/ext/rugged/rugged_blob.c +638 -0
- data/ext/rugged/rugged_branch.c +195 -0
- data/ext/rugged/rugged_branch_collection.c +408 -0
- data/ext/rugged/rugged_commit.c +691 -0
- data/ext/rugged/rugged_config.c +404 -0
- data/ext/rugged/rugged_cred.c +148 -0
- data/ext/rugged/rugged_diff.c +686 -0
- data/ext/rugged/rugged_diff_delta.c +105 -0
- data/ext/rugged/rugged_diff_hunk.c +103 -0
- data/ext/rugged/rugged_diff_line.c +83 -0
- data/ext/rugged/rugged_index.c +1255 -0
- data/ext/rugged/rugged_note.c +376 -0
- data/ext/rugged/rugged_object.c +383 -0
- data/ext/rugged/rugged_patch.c +245 -0
- data/ext/rugged/rugged_reference.c +396 -0
- data/ext/rugged/rugged_reference_collection.c +446 -0
- data/ext/rugged/rugged_remote.c +691 -0
- data/ext/rugged/rugged_remote_collection.c +457 -0
- data/ext/rugged/rugged_repo.c +2669 -0
- data/ext/rugged/rugged_revwalk.c +495 -0
- data/ext/rugged/rugged_settings.c +155 -0
- data/ext/rugged/rugged_signature.c +106 -0
- data/ext/rugged/rugged_submodule.c +852 -0
- data/ext/rugged/rugged_submodule_collection.c +384 -0
- data/ext/rugged/rugged_tag.c +251 -0
- data/ext/rugged/rugged_tag_collection.c +347 -0
- data/ext/rugged/rugged_tree.c +919 -0
- data/lib/rugged.rb +23 -0
- data/lib/rugged/attributes.rb +41 -0
- data/lib/rugged/blob.rb +28 -0
- data/lib/rugged/branch.rb +19 -0
- data/lib/rugged/commit.rb +54 -0
- data/lib/rugged/console.rb +9 -0
- data/lib/rugged/credentials.rb +43 -0
- data/lib/rugged/diff.rb +20 -0
- data/lib/rugged/diff/delta.rb +53 -0
- data/lib/rugged/diff/hunk.rb +18 -0
- data/lib/rugged/diff/line.rb +47 -0
- data/lib/rugged/index.rb +13 -0
- data/lib/rugged/object.rb +7 -0
- data/lib/rugged/patch.rb +36 -0
- data/lib/rugged/reference.rb +7 -0
- data/lib/rugged/remote.rb +4 -0
- data/lib/rugged/repository.rb +227 -0
- data/lib/rugged/submodule_collection.rb +48 -0
- data/lib/rugged/tag.rb +50 -0
- data/lib/rugged/tree.rb +38 -0
- data/lib/rugged/version.rb +3 -0
- data/lib/rugged/walker.rb +5 -0
- metadata +146 -0
data/lib/rugged.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
begin
|
2
|
+
RUBY_VERSION =~ /(\d+.\d+)/
|
3
|
+
require "rugged/#{$1}/rugged"
|
4
|
+
rescue LoadError
|
5
|
+
require "rugged/rugged"
|
6
|
+
end
|
7
|
+
require 'rugged/index'
|
8
|
+
require 'rugged/object'
|
9
|
+
require 'rugged/commit'
|
10
|
+
require 'rugged/version'
|
11
|
+
require 'rugged/repository'
|
12
|
+
require 'rugged/reference'
|
13
|
+
require 'rugged/walker'
|
14
|
+
require 'rugged/tree'
|
15
|
+
require 'rugged/tag'
|
16
|
+
require 'rugged/branch'
|
17
|
+
require 'rugged/diff'
|
18
|
+
require 'rugged/patch'
|
19
|
+
require 'rugged/remote'
|
20
|
+
require 'rugged/credentials'
|
21
|
+
require 'rugged/attributes'
|
22
|
+
require 'rugged/blob'
|
23
|
+
require 'rugged/submodule_collection'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Rugged
|
2
|
+
class Repository
|
3
|
+
def attributes(path, options = {})
|
4
|
+
Attributes.new(self, path, options)
|
5
|
+
end
|
6
|
+
|
7
|
+
class Attributes
|
8
|
+
include Enumerable
|
9
|
+
|
10
|
+
LOAD_PRIORITIES = {
|
11
|
+
[:file, :index] => 0,
|
12
|
+
[:index, :file] => 1,
|
13
|
+
[:index] => 2,
|
14
|
+
}
|
15
|
+
|
16
|
+
def self.parse_opts(opt)
|
17
|
+
flags = LOAD_PRIORITIES[opt[:priority]] || 0
|
18
|
+
flags |= 4 if opt[:skip_system]
|
19
|
+
flags
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(repository, path, options = {})
|
23
|
+
@repository = repository
|
24
|
+
@path = path
|
25
|
+
@load_flags = Attributes.parse_opts(options)
|
26
|
+
end
|
27
|
+
|
28
|
+
def [](attribute)
|
29
|
+
@repository.fetch_attributes(@path, attribute, @load_flags)
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_h
|
33
|
+
@hash ||= @repository.fetch_attributes(@path, nil, @load_flags)
|
34
|
+
end
|
35
|
+
|
36
|
+
def each(&block)
|
37
|
+
to_h.each(&block)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/rugged/blob.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Rugged
|
2
|
+
class Blob
|
3
|
+
class HashSignature
|
4
|
+
WHITESPACE_DEFAULT = 0
|
5
|
+
WHITESPACE_IGNORE = 1
|
6
|
+
WHITESPACE_SMART = 2
|
7
|
+
end
|
8
|
+
|
9
|
+
def hashsig(options = 0)
|
10
|
+
@hashsig ||= HashSignature.new(self, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def similarity(other)
|
14
|
+
other_sig = case other
|
15
|
+
when HashSignature
|
16
|
+
other
|
17
|
+
when String
|
18
|
+
HashSignature.new(other)
|
19
|
+
when Blob
|
20
|
+
other.hashsig
|
21
|
+
else
|
22
|
+
raise TypeError, "Expected a Rugged::Blob, String or Rugged::Blob::HashSignature"
|
23
|
+
end
|
24
|
+
|
25
|
+
HashSignature.compare(self.hashsig, other_sig)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Rugged
|
2
|
+
class Branch < Rugged::Reference
|
3
|
+
def ==(other)
|
4
|
+
other.instance_of?(Rugged::Branch) &&
|
5
|
+
other.canonical_name == self.canonical_name
|
6
|
+
end
|
7
|
+
|
8
|
+
# Get the remote the branch belongs to.
|
9
|
+
#
|
10
|
+
# If the branch is remote returns the remote it belongs to.
|
11
|
+
# In case of local branch, it returns the remote of the branch
|
12
|
+
# it tracks or nil if there is no tracking branch.
|
13
|
+
#
|
14
|
+
def remote
|
15
|
+
remote_name = self.remote_name
|
16
|
+
@owner.remotes[remote_name] if remote_name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Rugged
|
2
|
+
class Commit
|
3
|
+
|
4
|
+
def self.prettify_message(msg, strip_comments = true)
|
5
|
+
Rugged::prettify_message(msg, strip_comments)
|
6
|
+
end
|
7
|
+
|
8
|
+
def inspect
|
9
|
+
"#<Rugged::Commit:#{object_id} {message: #{message.inspect}, tree: #{tree.inspect}, parents: #{parent_oids}}>"
|
10
|
+
end
|
11
|
+
|
12
|
+
def header_field?(field)
|
13
|
+
!!header_field(field)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Return a diff between this commit and its first parent or another commit or tree.
|
17
|
+
#
|
18
|
+
# See Rugged::Tree#diff for more details.
|
19
|
+
def diff(*args)
|
20
|
+
args.unshift(parents.first) if args.size == 1 && args.first.is_a?(Hash)
|
21
|
+
self.tree.diff(*args)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Return a diff between this commit and the workdir.
|
25
|
+
#
|
26
|
+
# See Rugged::Tree#diff_workdir for more details.
|
27
|
+
def diff_workdir(options = {})
|
28
|
+
self.tree.diff_workdir(options)
|
29
|
+
end
|
30
|
+
|
31
|
+
# The time when this commit was made effective. This is the same value
|
32
|
+
# as the +:time+ attribute for +commit.committer+.
|
33
|
+
#
|
34
|
+
# Returns a Time object
|
35
|
+
def time
|
36
|
+
@time ||= Time.at(self.epoch_time)
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_hash
|
40
|
+
{
|
41
|
+
:message => message,
|
42
|
+
:committer => committer,
|
43
|
+
:author => author,
|
44
|
+
:tree => tree,
|
45
|
+
:parents => parents,
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def modify(new_args, update_ref=nil)
|
50
|
+
args = self.to_hash.merge(new_args)
|
51
|
+
Commit.create(args, update_ref)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Rugged
|
2
|
+
module Credentials
|
3
|
+
# A plain-text username and password credential object.
|
4
|
+
class UserPassword
|
5
|
+
def initialize(options)
|
6
|
+
@username, @password = options[:username], options[:password]
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(url, username_from_url, allowed_types)
|
10
|
+
self
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# A ssh key credential object that can optionally be passphrase-protected
|
15
|
+
class SshKey
|
16
|
+
def initialize(options)
|
17
|
+
@username, @publickey, @privatekey, @passphrase = options[:username], options[:publickey], options[:privatekey], options[:passphrase]
|
18
|
+
end
|
19
|
+
|
20
|
+
def call(url, username_from_url, allowed_types)
|
21
|
+
self
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class SshKeyFromAgent
|
26
|
+
def initialize(options)
|
27
|
+
@username = options[:username]
|
28
|
+
end
|
29
|
+
|
30
|
+
def call(url, username_from_url, allowed_types)
|
31
|
+
self
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# A "default" credential usable for Negotiate mechanisms like NTLM or
|
36
|
+
# Kerberos authentication
|
37
|
+
class Default
|
38
|
+
def call(url, username_from_url, allowed_types)
|
39
|
+
self
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/rugged/diff.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rugged/diff/hunk'
|
2
|
+
require 'rugged/diff/line'
|
3
|
+
require 'rugged/diff/delta'
|
4
|
+
|
5
|
+
module Rugged
|
6
|
+
class Diff
|
7
|
+
include Enumerable
|
8
|
+
alias each each_patch
|
9
|
+
|
10
|
+
attr_reader :owner
|
11
|
+
|
12
|
+
def patches
|
13
|
+
each_patch.to_a
|
14
|
+
end
|
15
|
+
|
16
|
+
def deltas
|
17
|
+
each_delta.to_a
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Rugged
|
2
|
+
class Diff
|
3
|
+
class Delta
|
4
|
+
attr_reader :owner
|
5
|
+
alias diff owner
|
6
|
+
|
7
|
+
attr_reader :old_file
|
8
|
+
attr_reader :new_file
|
9
|
+
attr_reader :similarity
|
10
|
+
attr_reader :status
|
11
|
+
attr_reader :status_char
|
12
|
+
attr_reader :binary
|
13
|
+
|
14
|
+
alias binary? binary
|
15
|
+
|
16
|
+
def added?
|
17
|
+
status == :added
|
18
|
+
end
|
19
|
+
|
20
|
+
def deleted?
|
21
|
+
status == :deleted
|
22
|
+
end
|
23
|
+
|
24
|
+
def modified?
|
25
|
+
status == :modified
|
26
|
+
end
|
27
|
+
|
28
|
+
def renamed?
|
29
|
+
status == :renamed
|
30
|
+
end
|
31
|
+
|
32
|
+
def copied?
|
33
|
+
status == :copied
|
34
|
+
end
|
35
|
+
|
36
|
+
def ignored?
|
37
|
+
status == :ignored
|
38
|
+
end
|
39
|
+
|
40
|
+
def untracked?
|
41
|
+
status == :untracked
|
42
|
+
end
|
43
|
+
|
44
|
+
def typechange?
|
45
|
+
status == :typechange
|
46
|
+
end
|
47
|
+
|
48
|
+
def inspect
|
49
|
+
"#<#{self.class.name}:#{object_id} {old_file: #{old_file.inspect}, new_file: #{new_file.inspect}, similarity: #{similarity.inspect}, status: #{status.inspect}>"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Rugged
|
2
|
+
class Diff
|
3
|
+
class Hunk
|
4
|
+
def delta
|
5
|
+
@owner
|
6
|
+
end
|
7
|
+
|
8
|
+
def inspect
|
9
|
+
"#<#{self.class.name}:#{object_id} {header: #{header.inspect}, count: #{count.inspect}}>"
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns an Array containing all lines of the hunk.
|
13
|
+
def lines
|
14
|
+
each_line.to_a
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Rugged
|
2
|
+
class Diff
|
3
|
+
class Line
|
4
|
+
attr_reader :line_origin, :content, :old_lineno, :new_lineno, :content_offset
|
5
|
+
|
6
|
+
def context?
|
7
|
+
@line_origin == :context
|
8
|
+
end
|
9
|
+
|
10
|
+
def addition?
|
11
|
+
@line_origin == :addition
|
12
|
+
end
|
13
|
+
|
14
|
+
def deletion?
|
15
|
+
@line_origin == :deletion
|
16
|
+
end
|
17
|
+
|
18
|
+
def eof_no_newline?
|
19
|
+
@line_origin == :eof_no_newline
|
20
|
+
end
|
21
|
+
|
22
|
+
def eof_newline_added?
|
23
|
+
@line_origin == :eof_newline_added
|
24
|
+
end
|
25
|
+
|
26
|
+
def eof_newline_removed?
|
27
|
+
@line_origin == :eof_newline_removed
|
28
|
+
end
|
29
|
+
|
30
|
+
def file_header?
|
31
|
+
@line_origin == :file_header
|
32
|
+
end
|
33
|
+
|
34
|
+
def hunk_header?
|
35
|
+
@line_origin == :hunk_header
|
36
|
+
end
|
37
|
+
|
38
|
+
def binary?
|
39
|
+
@line_origin == :binary
|
40
|
+
end
|
41
|
+
|
42
|
+
def inspect
|
43
|
+
"#<#{self.class.name}:#{object_id} {line_origin: #{line_origin.inspect}, content: #{content.inspect}>"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/rugged/index.rb
ADDED
data/lib/rugged/patch.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Rugged
|
2
|
+
class Patch
|
3
|
+
include Enumerable
|
4
|
+
alias each each_hunk
|
5
|
+
|
6
|
+
alias size hunk_count
|
7
|
+
alias count hunk_count
|
8
|
+
|
9
|
+
attr_accessor :owner
|
10
|
+
alias diff owner
|
11
|
+
|
12
|
+
def inspect
|
13
|
+
"#<#{self.class.name}:#{object_id}>"
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns the number of additions in the patch.
|
17
|
+
def additions
|
18
|
+
stat[0]
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns the number of deletions in the patch.
|
22
|
+
def deletions
|
23
|
+
stat[1]
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the number of total changes in the patch.
|
27
|
+
def changes
|
28
|
+
additions + deletions
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns an Array containing all hunks of the patch.
|
32
|
+
def hunks
|
33
|
+
each_hunk.to_a
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|