itamae 1.0.0.beta18 → 1.0.0.beta19
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/itamae/resource/git.rb +35 -15
- data/lib/itamae/resource/link.rb +16 -1
- data/lib/itamae/version.txt +1 -1
- 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: dc6be533641d1880daf19c72aa07fd17819862c1
|
4
|
+
data.tar.gz: 0216f0b6a3a46479b0cf04071473285ef784d289
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b09eb043ac66fb22012bd925abf26be0b55038d8838bc4c9804249729acc6f6c809321bcd8b8f26274637f0784618fe47d9f5062b0945b3e3243b5d2198d3bb8
|
7
|
+
data.tar.gz: 8adc9ff795714ab8eedcee4ddd0a8ac5588f7571f0f67374b42506566a54577959f29eda5538b06fb0fe964269e87ea000912877067a53e963bb7c3d240a8f98
|
data/lib/itamae/resource/git.rb
CHANGED
@@ -10,34 +10,54 @@ module Itamae
|
|
10
10
|
define_attribute :repository, type: String, required: true
|
11
11
|
define_attribute :revision, type: String
|
12
12
|
|
13
|
+
def pre_action
|
14
|
+
case action
|
15
|
+
when :sync
|
16
|
+
@attributes[:exist?] = true
|
17
|
+
end
|
18
|
+
|
19
|
+
@attributes[:revision_hash] = if revision
|
20
|
+
get_revision(revision)
|
21
|
+
else
|
22
|
+
run_command_in_repo("git ls-remote origin HEAD | cut -f1").stdout.strip
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def set_current_attributes
|
27
|
+
exist = run_specinfra(:check_file_is_directory, destination)
|
28
|
+
@current_attributes[:exist?] = exist
|
29
|
+
|
30
|
+
if exist
|
31
|
+
@current_attributes[:revision_hash] = get_revision('HEAD')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
13
35
|
def sync_action
|
14
36
|
ensure_git_available
|
15
37
|
|
38
|
+
new_repository = false
|
39
|
+
|
16
40
|
if run_specinfra(:check_file_is_directory, destination)
|
17
41
|
run_command_in_repo(['git', 'fetch', 'origin'])
|
18
42
|
else
|
19
43
|
run_command(['git', 'clone', repository, destination])
|
20
|
-
|
44
|
+
new_repository = true
|
21
45
|
end
|
22
46
|
|
23
|
-
|
24
|
-
get_revision(revision) ||
|
25
|
-
run_command_in_repo("git ls-remote origin HEAD | cut -f1").stdout.strip
|
26
|
-
|
27
|
-
unless target_revision == get_revision('HEAD')
|
47
|
+
if new_repository || @attributes[:revision_hash] != get_revision('HEAD')
|
28
48
|
updated!
|
29
|
-
end
|
30
49
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
50
|
+
deploy_old_created = false
|
51
|
+
if current_branch == DEPLOY_BRANCH
|
52
|
+
run_command_in_repo("git branch -m deploy-old")
|
53
|
+
deploy_old_created = true
|
54
|
+
end
|
36
55
|
|
37
|
-
|
56
|
+
run_command_in_repo(["git", "checkout", @attributes[:revision_hash], "-b", DEPLOY_BRANCH])
|
38
57
|
|
39
|
-
|
40
|
-
|
58
|
+
if deploy_old_created
|
59
|
+
run_command_in_repo("git branch -d deploy-old")
|
60
|
+
end
|
41
61
|
end
|
42
62
|
end
|
43
63
|
|
data/lib/itamae/resource/link.rb
CHANGED
@@ -7,8 +7,23 @@ module Itamae
|
|
7
7
|
define_attribute :link, type: String, default_name: true
|
8
8
|
define_attribute :to, type: String, required: true
|
9
9
|
|
10
|
+
def pre_action
|
11
|
+
case action
|
12
|
+
when :create
|
13
|
+
@attributes[:exist?] = true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def set_current_attributes
|
18
|
+
@current_attributes[:exist?] = (run_command(["test", "-L", link]).exit_status == 0)
|
19
|
+
|
20
|
+
if @current_attributes[:exist?]
|
21
|
+
@current_attributes[:to] = run_command(["readlink", "-f", link]).stdout.strip
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
10
25
|
def create_action
|
11
|
-
|
26
|
+
unless run_specinfra(:check_file_is_linked_to, link, to)
|
12
27
|
run_specinfra(:link_file_to, link, to)
|
13
28
|
end
|
14
29
|
end
|
data/lib/itamae/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.
|
1
|
+
1.0.0.beta19
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itamae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|