docman 0.0.69 → 0.0.70

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cfada338b5ce6e3933b80a951142d7424f6f88f
4
- data.tar.gz: 7bc258320b19c0faa53316b67b2a54ba79ec7e9e
3
+ metadata.gz: 10005717e54be448ce35f02aa8d0ec48d66facf8
4
+ data.tar.gz: aa012e44fa94f8bac747aff2645820c718e221e6
5
5
  SHA512:
6
- metadata.gz: 951bb5f771f4fd4d1823f45ed5b03efeff03048bc6021fd2f90c630cffef075cdb44af3eaa805e59b2e7be12bf72551f6bc49f3f5079b9a0be280c60d6e3f7ac
7
- data.tar.gz: 80c7cb1ea9b88fac99e07e97bff921ae180be09f8ba5a6d9f398249186ff2dfef3fa70e0ed79ecdf56167a1a73a1bcec8422a3c8945cda804d326bc2637eecc6
6
+ metadata.gz: 5f677a8c437fc6a63975e463de020897e471d9be014d7da1cd123fef589cde563e2112750008aeaae243a1738d873df623480b0b9b51dd96f2c3093e37534697
7
+ data.tar.gz: d9d68d33374aad7b20b20fe0a25995d9ec2857f450f51489a85742dccddf945090ac41fdbfb6739c1b6ea4e479e0d8a542fb5d06a3d4e3292b07eaa2a27aaee3
@@ -5,6 +5,8 @@ deploy_targets:
5
5
  builders:
6
6
  root:
7
7
  handler: :dir_builder
8
+ root_chain:
9
+ handler: :git_direct_builder
8
10
  drupal:
9
11
  handler: :drupal_drush_builder
10
12
  repo:
@@ -26,6 +28,15 @@ deploy_targets:
26
28
  builder:
27
29
  after_execute:
28
30
  - type: :git_commit
31
+ order: 100
32
+ execution_dir: $PROJECT$
33
+ root_chain:
34
+ handler: :git_root_chain_builder
35
+ hooks:
36
+ builder:
37
+ after_execute:
38
+ - type: :git_commit
39
+ order: 100
29
40
  execution_dir: $PROJECT$
30
41
  drupal:
31
42
  handler: :drupal_drush_builder
@@ -33,6 +44,7 @@ deploy_targets:
33
44
  builder:
34
45
  after_execute:
35
46
  - type: :git_commit
47
+ order: 100
36
48
  execution_dir: $PROJECT$
37
49
  repo:
38
50
  handler: :git_strip_builder
@@ -40,6 +52,7 @@ deploy_targets:
40
52
  builder:
41
53
  after_execute:
42
54
  - type: :git_commit
55
+ order: 100
43
56
  execution_dir: $PROJECT$
44
57
  dir:
45
58
  handler: :dir_builder
@@ -47,6 +60,7 @@ deploy_targets:
47
60
  builder:
48
61
  after_execute:
49
62
  - type: :git_commit
63
+ order: 100
50
64
  execution_dir: $PROJECT$
51
65
  symlink:
52
66
  handler: :symlink_builder
@@ -54,6 +68,7 @@ deploy_targets:
54
68
  builder:
55
69
  after_execute:
56
70
  - type: :git_commit
71
+ order: 100
57
72
  execution_dir: $PROJECT$
58
73
  states:
59
74
  development: dev
@@ -16,6 +16,7 @@ require 'docman/builders/builder'
16
16
  require 'docman/builders/dir_builder'
17
17
  require 'docman/builders/symlink_builder'
18
18
  require 'docman/builders/git_direct_builder'
19
+ require 'docman/builders/git_root_chain_builder'
19
20
  require 'docman/builders/git_strip_builder'
20
21
  require 'docman/builders/drupal_drush_builder'
21
22
  require 'docman/deployers/deployer'
@@ -27,6 +28,7 @@ require 'docman/commands/create_symlink_cmd'
27
28
  require 'docman/commands/execute_script_cmd'
28
29
  require 'docman/commands/clean_changed_cmd'
29
30
  require 'docman/commands/git_commit_cmd'
31
+ require 'docman/commands/git_copy_repo_content_cmd'
30
32
  require 'docman/taggers/tagger'
31
33
  require 'docman/taggers/incremental_tagger'
32
34
  require 'docman/taggers/option_tagger'
@@ -35,7 +37,7 @@ module Docman
35
37
  class Application < Docman::Command
36
38
 
37
39
  attr_reader :config, :docroot_config
38
- attr_accessor :deploy_target, :options, :force
40
+ attr_accessor :deploy_target, :options, :force, :commit_count
39
41
 
40
42
  include Singleton
41
43
  include Docman::Context
@@ -45,6 +47,7 @@ module Docman
45
47
  @workspace_dir = Dir.pwd
46
48
  @config = Docman::Config.new(File.join(Pathname(__FILE__).dirname.parent, 'config', 'config.yaml'))
47
49
  @force = false
50
+ @commit_count = 0
48
51
  end
49
52
 
50
53
  def init(name, repo, options)
@@ -13,9 +13,15 @@ module Docman
13
13
 
14
14
  def changed?
15
15
  stored_version = @context.stored_version['result']
16
- @last_revision = GitUtil.last_revision @context['full_build_path']
16
+ if @context['type'] == 'root_chain'
17
+ repo_path = @context['temp_path']
18
+ else
19
+ repo_path = @context['full_build_path']
20
+ end
21
+
22
+ @last_revision = GitUtil.last_revision(repo_path)
17
23
  # No commit hash for 'root' as it will be changed later
18
- @version = @context['type'] == 'root' ? @context['build_path'] : GitUtil.get(@context['repo'], @context['full_build_path'], @context.version_type, @context.version)
24
+ @version = @context['type'] == 'root' ? @context['build_path'] : GitUtil.get(@context['repo'], repo_path, @context.version_type, @context.version)
19
25
  stored_version != @version
20
26
  end
21
27
 
@@ -0,0 +1,23 @@
1
+ module Docman
2
+ module Builders
3
+ class GitRootChainBuilder < Builder
4
+
5
+ register_builder :git_root_chain_builder
6
+
7
+ def execute
8
+ GitUtil.get(@context['root_repo'], @context['full_build_path'], @context.version_type(type: 'root'), @context.version(type: 'root'))
9
+ @version = Docman::Command.create({'type' => :git_copy_repo_content, 'remove_target' => true}, @context, self).perform
10
+ @last_revision != @version ? @version : false
11
+ end
12
+
13
+ def changed?
14
+ stored_version = @context.stored_version['result']
15
+ @last_revision = GitUtil.last_revision @context['temp_path']
16
+ # No commit hash for 'root' as it will be changed later
17
+ @version = GitUtil.get(@context['repo'], @context['temp_path'], @context.version_type, @context.version)
18
+ stored_version != @version
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -15,6 +15,8 @@ module Docman
15
15
  return false if @context['type'] == 'dir'
16
16
  return false if @context['type'] == 'root' and @context['build_type'] == :dir_builder and not GitUtil.repo?(@context['full_build_path'])
17
17
  return false if @context['type'] == 'root' and @context['build_type'] == :git_direct_builder and GitUtil.repo?(@context['full_build_path'])
18
+ return false if @context['type'] == 'root_chain' and @context['build_type'] == :git_direct_builder and GitUtil.repo?(@context['full_build_path'])
19
+ return false if @context['type'] == 'root_chain' and @context['build_type'] == :git_root_chain_builder and GitUtil.repo?(@context['full_build_path'])
18
20
  if @context['type'] == 'repo'
19
21
  if @context['build_type'] == :git_direct_builder
20
22
  return false if GitUtil.repo?(@context['full_build_path'])
@@ -53,6 +53,7 @@ module Docman
53
53
  hooks = Marshal::load(Marshal.dump(hooks))
54
54
  unless context.nil? or hooks.nil?
55
55
  hooks.each do |hook|
56
+ hook['order'] = 0 unless hook['order']
56
57
  hook['context'] = context
57
58
  end
58
59
  end
@@ -66,6 +67,7 @@ module Docman
66
67
  end
67
68
 
68
69
  def add_action(name, hook, context = nil)
70
+ hook['order'] = 0 unless hook['order']
69
71
  if @hooks.has_key? name
70
72
  @hooks[name] << {'type' => hook}
71
73
  else
@@ -75,6 +77,7 @@ module Docman
75
77
 
76
78
  def run_actions(name)
77
79
  if @hooks.has_key?(name) and not @hooks[name].nil?
80
+ @hooks[name].sort_by!{|a| a['order']}
78
81
  @hooks[name].each do |hook|
79
82
  next if hook.has_key?('run_on_success_only') and hook['run_on_success_only'] and not @execute_result
80
83
  context = hook.has_key?('context') ? hook['context'] : @context
@@ -0,0 +1,23 @@
1
+ module Docman
2
+ class GitCopyRepoContent < Docman::Command
3
+
4
+ register_command :git_copy_repo_content
5
+
6
+ def validate_command
7
+ raise "Please provide 'context'" if @context.nil?
8
+ raise "Context should be of type 'Info'" unless @context.is_a? Docman::Info
9
+ end
10
+
11
+ def execute
12
+ if (self['remove_target'])
13
+ FileUtils.rm_r(Dir["#{@context['full_build_path']}/*"]) if File.directory? @context['full_build_path']
14
+ end
15
+ FileUtils.rm_r @context['temp_path'] if @context.need_rebuild? and File.directory? @context['temp_path']
16
+ @version = GitUtil.get(@context['repo'], @context['temp_path'], @context.version_type, @context.version, nil, nil)
17
+ # FileUtils.rm_r(File.join(@context['temp_path'], '.git')) if File.directory?(File.join(@context['temp_path'], '.git'))
18
+ FileUtils.mkdir_p(@context['full_build_path'])
19
+ `rsync -a --exclude '.git' #{@context['temp_path']}/. #{@context['full_build_path']}`
20
+ @version
21
+ end
22
+ end
23
+ end
@@ -146,8 +146,8 @@ module Docman
146
146
  if item.need_rebuild?
147
147
  build_recursive(item)
148
148
  return
149
- elsif
150
- build_dir(item)
149
+ else
150
+ build_dir(item)
151
151
  end
152
152
  end
153
153
  end
@@ -171,6 +171,12 @@ module Docman
171
171
  @build_results[info['name']] = build_result ? build_result : 'Not builded'
172
172
  @versions[info['name']] = builder.version
173
173
  @builded << info['name']
174
+ if (build_result)
175
+ info['children'].sort_by!{|a| a['order']}
176
+ info['children'].each do |child|
177
+ build_recursive(child)
178
+ end
179
+ end
174
180
  end
175
181
 
176
182
  # TODO: need to refactor.
@@ -24,7 +24,8 @@ module Docman
24
24
  end
25
25
 
26
26
  GitUtil.commit(root['full_build_path'], root['full_build_path'], 'Updated version', tag)
27
- GitUtil.push(root['full_build_path'], root.version)
27
+ GitUtil.squash_commits(Docman::Application.instance.commit_count)
28
+ GitUtil.push(root['full_build_path'], root.version(type: 'root'))
28
29
  end
29
30
 
30
31
  end
@@ -96,17 +96,9 @@ module Docman
96
96
  Digest::MD5.hexdigest(Marshal::dump(@raw_infos))
97
97
  end
98
98
 
99
- def root_path
100
- @root['fuil_build_path']
101
- end
102
-
103
99
  def deploy_target_name
104
100
  @deploy_target.name
105
101
  end
106
102
 
107
- def root_states
108
- @root.states
109
- end
110
-
111
103
  end
112
104
  end
@@ -1,17 +1,12 @@
1
1
  require 'docman/builders/builder'
2
2
  require 'docman/builders/dir_builder'
3
3
  require 'docman/builders/git_direct_builder'
4
+ require 'docman/builders/git_root_chain_builder'
4
5
  require 'docman/builders/git_strip_builder'
5
6
  require 'docman/builders/drupal_drush_builder'
6
7
  require 'docman/deployers/deployer'
7
8
  require 'docman/deployers/git_deployer'
8
9
  require 'docman/deployers/common_deployer'
9
- require 'docman/command'
10
- require 'docman/composite_command'
11
- require 'docman/builders/commands/create_symlink_cmd'
12
- require 'docman/builders/commands/execute_script_cmd'
13
- require 'docman/builders/commands/clean_changed_cmd'
14
- require 'docman/builders/commands/git_commit_cmd'
15
10
 
16
11
  # TODO: make universal logging class.
17
12
 
@@ -15,6 +15,12 @@ module Docman
15
15
  result
16
16
  end
17
17
 
18
+ def self.squash_commits(commit_count, message = nil)
19
+ message = "$(git log --format=%B --reverse HEAD..HEAD@{1})" unless message
20
+ exec "reset --soft HEAD~#{commit_count}"
21
+ exec "commit -m \"#{message}\""
22
+ end
23
+
18
24
  def self.reset_repo(path)
19
25
  Dir.chdir path
20
26
  exec 'reset --hard'
@@ -74,11 +80,11 @@ module Docman
74
80
 
75
81
  def self.commit(root_path, path, message, tag = nil)
76
82
  if repo_changed? path
77
- # puts message
78
83
  pull root_path
79
84
  exec %Q(add --all #{path.slice "#{root_path}/"})
80
85
  exec %Q(commit -m "#{message}") if repo_changed? path
81
86
  self.tag(root_path, tag) if tag
87
+ Docman::Application.instance.commit_count = Docman::Application.instance.commit_count + 1
82
88
  end
83
89
  end
84
90
 
@@ -21,6 +21,7 @@ module Docman
21
21
  self['states'].each_pair do |name, state|
22
22
  if state.has_key?('source')
23
23
  if state['source']['type'] == :retrieve_from_repo
24
+ @state_name = name
24
25
  repo = state['source']['repo'] == :project_repo ? self['repo'] : state['source']['repo']
25
26
  external_state_info = read_yaml_from_file(repo, self['states_path'], state['source']['branch'], state['source']['file'])
26
27
  state.deep_merge! external_state_info unless external_state_info.nil? or state.nil?
@@ -32,7 +33,7 @@ module Docman
32
33
  end
33
34
 
34
35
  def read_yaml_from_file(repo, path, version, filename)
35
- GitUtil.get(repo, path, 'branch', version, true, 1, need_rebuild?)
36
+ GitUtil.get(repo, path, 'branch', version, true, 1, true)
36
37
  filepath = File.join(path, filename)
37
38
  return YAML::load_file(filepath) if File.file? filepath
38
39
  nil
@@ -40,12 +41,12 @@ module Docman
40
41
  raise "Error in info file: #{filepath}, #{e.message}"
41
42
  end
42
43
 
43
- def version
44
- state.nil? ? nil : state['version']
44
+ def version(options = {})
45
+ state(options).nil? ? nil : state(options)['version']
45
46
  end
46
47
 
47
- def version_type
48
- state.nil? ? nil : state['type']
48
+ def version_type(options = {})
49
+ state(options).nil? ? nil : state(options)['type']
49
50
  end
50
51
 
51
52
  def describe(type = 'short')
@@ -117,12 +118,16 @@ module Docman
117
118
  YAML::load_file(info_filename)
118
119
  end
119
120
 
120
- def state
121
- states[@state_name]
121
+ def state(options = {})
122
+ states(options)[@state_name]
122
123
  end
123
124
 
124
- def states
125
- self['states']
125
+ def states(options = {})
126
+ if options[:type] == 'root' and self['type'] == 'root_chain'
127
+ self['root_repo_states']
128
+ else
129
+ self['states']
130
+ end
126
131
  end
127
132
 
128
133
  def disabled?
@@ -1,3 +1,3 @@
1
1
  module Docman
2
- VERSION = "0.0.69"
2
+ VERSION = "0.0.70"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.69
4
+ version: 0.0.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Tolstikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-11 00:00:00.000000000 Z
11
+ date: 2016-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -174,6 +174,7 @@ files:
174
174
  - lib/docman/builders/dir_builder.rb
175
175
  - lib/docman/builders/drupal_drush_builder.rb
176
176
  - lib/docman/builders/git_direct_builder.rb
177
+ - lib/docman/builders/git_root_chain_builder.rb
177
178
  - lib/docman/builders/git_strip_builder.rb
178
179
  - lib/docman/builders/symlink_builder.rb
179
180
  - lib/docman/cli.rb
@@ -183,6 +184,7 @@ files:
183
184
  - lib/docman/commands/create_symlink_cmd.rb
184
185
  - lib/docman/commands/execute_script_cmd.rb
185
186
  - lib/docman/commands/git_commit_cmd.rb
187
+ - lib/docman/commands/git_copy_repo_content_cmd.rb
186
188
  - lib/docman/commands/ssh_target_checker.rb
187
189
  - lib/docman/commands/target_checker.rb
188
190
  - lib/docman/config.rb