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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6407849af1c1881162cdce67e8312ad543f5b80
4
- data.tar.gz: fa1d01ec1165d160b643671a719bebb49cba93f0
3
+ metadata.gz: dc6be533641d1880daf19c72aa07fd17819862c1
4
+ data.tar.gz: 0216f0b6a3a46479b0cf04071473285ef784d289
5
5
  SHA512:
6
- metadata.gz: e8a4f249629869ce532e457c8f9878db2915eadb99ba5acbfde9ae01d93197102badaa2d0ae98c5ab34b39b1c4bc6b6f005b8a38ee132fcec2d96ce1914e1280
7
- data.tar.gz: 00a927b247a787b915f940c95b867c7bff45809997e947426d26e7574c0387b16893d210bf57c0c35183ac4e9dcc4a5051063f9fe0c5a09303e8a0aa6d77d581
6
+ metadata.gz: b09eb043ac66fb22012bd925abf26be0b55038d8838bc4c9804249729acc6f6c809321bcd8b8f26274637f0784618fe47d9f5062b0945b3e3243b5d2198d3bb8
7
+ data.tar.gz: 8adc9ff795714ab8eedcee4ddd0a8ac5588f7571f0f67374b42506566a54577959f29eda5538b06fb0fe964269e87ea000912877067a53e963bb7c3d240a8f98
@@ -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
- updated!
44
+ new_repository = true
21
45
  end
22
46
 
23
- target_revision =
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
- deploy_old_created = false
32
- if current_branch == DEPLOY_BRANCH
33
- run_command_in_repo("git branch -m deploy-old")
34
- deploy_old_created = true
35
- end
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
- run_command_in_repo(["git", "checkout", target_revision, "-b", DEPLOY_BRANCH])
56
+ run_command_in_repo(["git", "checkout", @attributes[:revision_hash], "-b", DEPLOY_BRANCH])
38
57
 
39
- if deploy_old_created
40
- run_command_in_repo("git branch -d deploy-old")
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
 
@@ -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
- if ! run_specinfra(:check_file_is_linked_to, link, to)
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
@@ -1 +1 @@
1
- 1.0.0.beta18
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.beta18
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-21 00:00:00.000000000 Z
11
+ date: 2014-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor