dandelion 0.4.17 → 0.5.0
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 +4 -4
- data/lib/dandelion/adapter/noop.rb +3 -0
- data/lib/dandelion/adapter/sftp.rb +13 -0
- data/lib/dandelion/change.rb +1 -1
- data/lib/dandelion/changeset.rb +6 -1
- data/lib/dandelion/deployer.rb +7 -0
- data/lib/dandelion/tree.rb +8 -30
- data/lib/dandelion/version.rb +1 -1
- data/spec/dandelion/changeset_spec.rb +26 -0
- data/spec/dandelion/tree_spec.rb +2 -2
- data/spec/spec_helper.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfa2a084aedc78ea79f21a41bf1536aca3f1709b
|
4
|
+
data.tar.gz: baab9852c5d2adea02a24839e37a40c2234eeb10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a6782c6f02a58ea73d9f878d717884bb0143039ca9d0be142ab919095c75e2e181e2c3eeeab49bcefc46c65c1eb671315b00e634b14618d7ef6d906d81f5f14
|
7
|
+
data.tar.gz: 6b89c90540d0d5d0d908467528b8636d2a5af0f35cbf462f748e315aec3524b1b8c04698327f96ecddebdab3b8dda99e13e8b95e87727a4f4e6280fbf32a4b95
|
@@ -55,6 +55,19 @@ module Dandelion
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
def symlink(file, target)
|
59
|
+
begin
|
60
|
+
@sftp.symlink!(target, path(file))
|
61
|
+
rescue Net::SFTP::StatusException => e
|
62
|
+
if e.code == 2
|
63
|
+
mkdir_p(File.dirname(path(file)))
|
64
|
+
else
|
65
|
+
@sftp.remove!(path(file))
|
66
|
+
end
|
67
|
+
@sftp.symlink!(target, path(file))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
58
71
|
def to_s
|
59
72
|
"sftp://#{@config['username']}@#{@config['host']}/#{@config['path']}"
|
60
73
|
end
|
data/lib/dandelion/change.rb
CHANGED
data/lib/dandelion/changeset.rb
CHANGED
@@ -25,7 +25,12 @@ module Dandelion
|
|
25
25
|
yield Change.new(path, change.type)
|
26
26
|
else
|
27
27
|
read = -> { @tree.data(change.path) }
|
28
|
-
|
28
|
+
|
29
|
+
if @tree.is_symlink?(change.path)
|
30
|
+
yield Change.new(path, :symlink, read)
|
31
|
+
else
|
32
|
+
yield Change.new(path, change.type, read)
|
33
|
+
end
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|
data/lib/dandelion/deployer.rb
CHANGED
@@ -50,6 +50,13 @@ module Dandelion
|
|
50
50
|
when :delete
|
51
51
|
log.debug("Deleting file: #{change.path}")
|
52
52
|
@adapter.delete(change.path)
|
53
|
+
when :symlink
|
54
|
+
if @adapter.respond_to?(:symlink)
|
55
|
+
log.debug("Creating symlink: #{change.path}")
|
56
|
+
@adapter.symlink(change.path, change.data)
|
57
|
+
else
|
58
|
+
log.debug("Skipped creating symlink: #{change.path} -> #{change.data}")
|
59
|
+
end
|
53
60
|
end
|
54
61
|
end
|
55
62
|
|
data/lib/dandelion/tree.rb
CHANGED
@@ -7,6 +7,11 @@ module Dandelion
|
|
7
7
|
@commit = commit
|
8
8
|
end
|
9
9
|
|
10
|
+
def is_symlink?(path)
|
11
|
+
# https://github.com/libgit2/libgit2/blob/development/include/git2/types.h
|
12
|
+
@commit.tree.path(path)[:filemode] == 0120000
|
13
|
+
end
|
14
|
+
|
10
15
|
def data(path)
|
11
16
|
submodule = @repo.submodules[path]
|
12
17
|
|
@@ -15,48 +20,21 @@ module Dandelion
|
|
15
20
|
nil
|
16
21
|
else
|
17
22
|
info, obj = object(path)
|
18
|
-
|
23
|
+
blob_content(obj)
|
19
24
|
end
|
20
25
|
end
|
21
26
|
|
22
27
|
private
|
23
28
|
|
24
29
|
def object(path)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
path.split('/').each do |name|
|
29
|
-
info = object[name]
|
30
|
-
return nil unless info
|
31
|
-
return nil unless info[:type]
|
32
|
-
|
33
|
-
object = @repo.lookup(info[:oid])
|
34
|
-
|
35
|
-
return nil unless object
|
36
|
-
end
|
37
|
-
|
30
|
+
info = @commit.tree.path(path)
|
31
|
+
object = @repo.lookup(info[:oid])
|
38
32
|
[info, object]
|
39
33
|
end
|
40
34
|
|
41
|
-
def content(info, object)
|
42
|
-
# https://github.com/libgit2/libgit2/blob/development/include/git2/types.h
|
43
|
-
if info[:filemode] == 0120000
|
44
|
-
symlink_content(object)
|
45
|
-
else
|
46
|
-
blob_content(object)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
35
|
def blob_content(object)
|
51
36
|
object.read_raw.data
|
52
37
|
end
|
53
38
|
|
54
|
-
def symlink_content(object)
|
55
|
-
path = object.read_raw.data
|
56
|
-
|
57
|
-
result = data(path)
|
58
|
-
result ||= IO.binread(path) # external link
|
59
|
-
result
|
60
|
-
end
|
61
39
|
end
|
62
40
|
end
|
data/lib/dandelion/version.rb
CHANGED
@@ -70,4 +70,30 @@ describe Dandelion::Changeset do
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
73
|
+
|
74
|
+
context 'diff adds symlink' do
|
75
|
+
let(:changeset) { test_changeset_with_symlinks }
|
76
|
+
|
77
|
+
describe '#enumerable' do
|
78
|
+
let(:changes) { changeset.to_a }
|
79
|
+
|
80
|
+
it 'returns all changes' do
|
81
|
+
expect(changes).to be_a(Array)
|
82
|
+
expect(changes.length).to eq 1
|
83
|
+
expect(changes.map(&:path)).to eq ['link']
|
84
|
+
expect(changes.map(&:type)).to eq [:symlink]
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'returns data for write changes' do
|
88
|
+
expect(changes.select { |c| c.type != :delete }.map(&:data)).to eq ["baz/bar"]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#empty?' do
|
93
|
+
it 'returns false' do
|
94
|
+
expect(changeset.empty?).to eq false
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
73
99
|
end
|
data/spec/dandelion/tree_spec.rb
CHANGED
@@ -16,8 +16,8 @@ describe Dandelion::Tree do
|
|
16
16
|
let(:repo) { test_repo('repo_symlink') }
|
17
17
|
let(:tree) { test_tree(repo: repo, commit: repo.lookup('4c19bbe7ba04230a0ae2281c1abbc48a76a66550')) }
|
18
18
|
|
19
|
-
it 'returns
|
20
|
-
expect(tree.data('link')).to eq "bar
|
19
|
+
it 'returns target path of the symlink' do
|
20
|
+
expect(tree.data('link')).to eq "baz/bar"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
data/spec/spec_helper.rb
CHANGED
@@ -27,6 +27,14 @@ def test_changeset(options = {})
|
|
27
27
|
Dandelion::Changeset.new(test_tree, test_commits.first, options)
|
28
28
|
end
|
29
29
|
|
30
|
+
def test_changeset_with_symlinks(options = {})
|
31
|
+
repo = test_repo('repo_symlink')
|
32
|
+
commit0 = repo.lookup('3d9b743acb4a84dd99002d2c6f3fcf1a47e9f06b')
|
33
|
+
commit1 = repo.lookup('4c19bbe7ba04230a0ae2281c1abbc48a76a66550')
|
34
|
+
tree = test_tree(repo: repo, commit: commit1)
|
35
|
+
Dandelion::Changeset.new(tree, commit0, options)
|
36
|
+
end
|
37
|
+
|
30
38
|
def test_diff
|
31
39
|
test_changeset.diff
|
32
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dandelion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Nelson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|