docman 0.0.16 → 0.0.17

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: 31a8e8ab8ea33da04a99253e913fa7c525f6894b
4
- data.tar.gz: 24d389f37957c2dcb57a1f0c427dd6b13e9a5490
3
+ metadata.gz: 19f94ad0fa7db90b3885c21db21c601d3f88b3c6
4
+ data.tar.gz: 31ecc7e39088113ca2b6641b011f2108656dd3e9
5
5
  SHA512:
6
- metadata.gz: bf122265863bbb5756c8d165f172c3674813cb3668c146c6a1984c95cf7f9cbd927ed972bcda4039d187f8fdb7815e0d9cd9f06518973ffc4552be4e8a4eda51
7
- data.tar.gz: d9f7cb95ab1acb5240e57e1c5ba73136e2142f44bb10c71fcc00e393bc70c8656cdb8570c425f8b9313c3a919eb673f9f495f1b1eea4061977246e18ee42a4c1
6
+ metadata.gz: 769e911a9c9f66418a64b249721a64c7e0db4e654bc5cea51f054bc70eca865c44de340e10d9b990f93009a157157af9c03e74049b895c2a4fb2a980707e9541
7
+ data.tar.gz: 371f377760e27394464e5fecb117d0f883f82f06b27f1416faad1dacdef35cd039306a9261017755132dad5b4dce6ec99cb31f1f5a69b98524438ce6929e907f
@@ -57,7 +57,7 @@ else
57
57
  echo "" >> CHANGES
58
58
  git add VERSION CHANGES
59
59
  git commit -m "Added VERSION and CHANGES files, Version bump to 0.1.0"
60
- git tag -a -m "[skip trigger] Tagging version 0.1.0" "0.1.0"
60
+ git tag -a -m "[skip] Tagging version 0.1.0" "0.1.0"
61
61
  git push origin --tags
62
62
  git push
63
63
  fi
@@ -77,7 +77,7 @@ if [ -n "$1" ]; then
77
77
  echo "type: tag" > info.yaml
78
78
  echo "version: $TAG" >> info.yaml
79
79
  git add -A
80
- git commit -m "[skip trigger] Changed tag to: $TAG" & git push origin ${BRANCH}
80
+ git commit -m "[skip] Changed tag to: $TAG" & git push origin ${BRANCH}
81
81
  git checkout -
82
82
  echo ${TAG}
83
83
  fi
@@ -46,46 +46,55 @@ module Docman
46
46
  end
47
47
 
48
48
  def init(name, repo)
49
- `mkdir #{name} && cd #{name} && git clone #{repo} config`
49
+ `mkdir #{name} && cd #{name} && git clone --depth 1 #{repo} config`
50
+ end
51
+
52
+ def with_rescue
53
+ failed_filepath = File.join(@workspace_dir, 'failed')
54
+ if File.file?(failed_filepath)
55
+ log 'Last operation failed, forced rebuild mode'
56
+ FileUtils.rm_f failed_filepath
57
+ @force = true
58
+ end
59
+ yield
60
+ rescue Exception => e
61
+ log "Operation failed: #{e.message}", 'error'
62
+ File.open(failed_filepath, 'w') {|f| f.write('Failed!') }
63
+ raise e
50
64
  end
51
65
 
52
66
  def build(deploy_target_name, state, options = false)
53
- @options = options
54
- @deploy_target = @config['deploy_targets'][deploy_target_name]
55
- @deploy_target['name'] = deploy_target_name
56
- @docroot_config = DocrootConfig.new(@workspace_dir, deploy_target)
57
- execute('build', state, nil, options['tag'])
67
+ with_rescue do
68
+ @options = options
69
+ @deploy_target = @config['deploy_targets'][deploy_target_name]
70
+ @deploy_target['name'] = deploy_target_name
71
+ @docroot_config = DocrootConfig.new(@workspace_dir, deploy_target)
72
+ execute('build', state, nil, options['tag'])
73
+ end
58
74
  end
59
75
 
60
76
  def deploy(deploy_target_name, name, type, version, options = false)
61
- @options = options
62
- @deploy_target = @config['deploy_targets'][deploy_target_name]
63
- raise "Wrong deploy target: #{deploy_target_name}" if @deploy_target.nil?
64
- @deploy_target['name'] = deploy_target_name
65
- @docroot_config = DocrootConfig.new(@workspace_dir, deploy_target)
66
- @docroot_config.states_dependin_on(name, version).keys.each do |state|
67
- execute('deploy', state, name)
77
+ with_rescue do
78
+ @options = options
79
+ @deploy_target = @config['deploy_targets'][deploy_target_name]
80
+ raise "Wrong deploy target: #{deploy_target_name}" if @deploy_target.nil?
81
+ @deploy_target['name'] = deploy_target_name
82
+ @docroot_config = DocrootConfig.new(@workspace_dir, deploy_target)
83
+ @docroot_config.states_dependin_on(name, version).keys.each do |state|
84
+ execute('deploy', state, name)
85
+ end
68
86
  end
69
87
  end
70
88
 
71
89
  def execute(action, state, name = nil, tag = nil)
72
90
  params = Marshal.load(Marshal.dump(@deploy_target))
73
- failed_filepath = File.join(@workspace_dir, 'failed')
74
- if File.file?(failed_filepath)
75
- log 'Last operation failed, forced rebuild mode'
76
- FileUtils.rm_f failed_filepath
77
- @force = true
78
- end
79
91
  params['state'] = state
80
92
  params['action'] = action
81
93
  params['name'] = name
82
- params['tag'] = tag
94
+ params['tag'] = tag ? tag : state + '-' + Time.now.strftime("%Y-%m-%d-%H-%M-%S")
83
95
  params['environment'] = @config['environments'][@deploy_target['states'][state]]
84
96
  params['environment_name'] = @deploy_target['states'][state]
85
97
  Docman::Deployers::Deployer.create(params, nil, self).perform
86
- rescue Exception => e
87
- log "Operation failed: #{e.message}", 'error'
88
- File.open(failed_filepath, 'w') {|f| f.write('Failed!') }
89
98
  end
90
99
 
91
100
  def force?
@@ -6,8 +6,8 @@ module Docman
6
6
 
7
7
  def execute
8
8
  FileUtils.rm_r(@context['full_build_path']) if File.directory? @context['full_build_path']
9
- # FileUtils.rm_r @context['temp_path'] if @context.need_rebuild? and File.directory? @context['temp_path']
10
- @version = GitUtil.get(@context['repo'], @context['temp_path'], @context.version_type, @context.version)
9
+ FileUtils.rm_r @context['temp_path'] if @context.need_rebuild? and File.directory? @context['temp_path']
10
+ @version = GitUtil.get(@context['repo'], @context['temp_path'], @context.version_type, @context.version, nil, nil)
11
11
  FileUtils.mkdir_p(@context['full_build_path'])
12
12
  FileUtils.cp_r(Dir["#{@context['temp_path']}/."], @context['full_build_path'])
13
13
  FileUtils.rm_r(File.join(@context['full_build_path'], '.git')) if File.directory?(File.join(@context['full_build_path'], '.git'))
@@ -16,7 +16,7 @@ module Docman
16
16
 
17
17
  def changed?
18
18
  stored_version = @context.stored_version['result']
19
- @version = GitUtil.get(@context['repo'], @context['temp_path'], @context.version_type, @context.version)
19
+ @version = GitUtil.get(@context['repo'], @context['temp_path'], @context.version_type, @context.version, nil, nil)
20
20
  stored_version != @version
21
21
  end
22
22
 
@@ -36,7 +36,7 @@ module Docman
36
36
  say('Complete!', :green)
37
37
  end
38
38
 
39
- desc 'build NAME', 'init to NAME'
39
+ desc 'build', 'Build docroot'
40
40
  method_option :force, :aliases => '-f', :desc => 'Force full rebuild'
41
41
  option :tag
42
42
  def build(deploy_target, state)
@@ -48,7 +48,7 @@ module Docman
48
48
  say('Complete!', :green)
49
49
  end
50
50
 
51
- desc 'deploy NAME', 'init to NAME'
51
+ desc 'deploy', 'Deploy to target'
52
52
  method_option :force, :aliases => '-f', :desc => 'Force full deploy'
53
53
  def deploy(deploy_target, name, type, version)
54
54
  if version.start_with?('state_')
@@ -61,19 +61,9 @@ module Docman
61
61
  end
62
62
  end
63
63
 
64
- desc 'state NAME', 'init to NAME'
65
- def state(name, type, version)
66
- config_dir?
67
- Application.instance.state(name, type, version)
68
- say('Complete!', :green)
69
- end
70
-
71
64
  no_commands {
72
65
  def config_dir?
73
- unless File.directory?('config')
74
- $stderr.puts 'ERROR: No config directory in docroot'
75
- exit 1
76
- end
66
+ raise 'ERROR: No config directory in docroot' unless File.directory?('config')
77
67
  end
78
68
  }
79
69
  end
@@ -12,8 +12,6 @@ module Docman
12
12
 
13
13
  @@deployers = {}
14
14
 
15
- #todo: docroot config in separate repos for projects
16
-
17
15
  def self.create(params, context = nil, caller = nil)
18
16
  c = @@deployers[params['handler']]
19
17
  if c
@@ -150,6 +148,14 @@ module Docman
150
148
  end
151
149
  end
152
150
 
151
+ def build_recursive(info = nil)
152
+ info = info ? info : @docroot_config.structure
153
+ build_dir(info)
154
+ info['children'].each do |child|
155
+ build_recursive(child)
156
+ end
157
+ end
158
+
153
159
  def build_dir(info)
154
160
  return if @builded.include? info['name']
155
161
  info.state_name = self['state']
@@ -162,15 +168,6 @@ module Docman
162
168
  @builded << info['name']
163
169
  end
164
170
 
165
- def build_recursive(info = nil)
166
- info = info ? info : @docroot_config.structure
167
- build_dir(info)
168
-
169
- info['children'].each do |child|
170
- build_recursive(child)
171
- end
172
- end
173
-
174
171
  # TODO: need to refactor.
175
172
  def describe(type = 'short')
176
173
  properties_info(['handler'])
@@ -20,7 +20,8 @@ module Docman
20
20
  exec 'git clean -f -d'
21
21
  end
22
22
 
23
- def self.get(repo, path, type, version)
23
+ def self.get(repo, path, type, version, single_branch = nil, depth = nil, reset = false)
24
+ FileUtils.rm_rf path if reset and File.directory? path
24
25
  if File.directory? path and File.directory?(File.join(path, '.git'))
25
26
  Dir.chdir path
26
27
  self.reset_repo(path) #if self.repo_changed?(path)
@@ -35,7 +36,14 @@ module Docman
35
36
  end
36
37
  else
37
38
  FileUtils.rm_rf path if File.directory? path
38
- exec "git clone #{repo} #{path}"
39
+ if type == 'branch'
40
+ single_branch = single_branch ? "-b #{version} --single-branch" : ''
41
+ depth = (depth and depth.is_a? Integer) ? "--depth #{depth}" : ''
42
+ else
43
+ single_branch=''
44
+ depth=''
45
+ end
46
+ exec "git clone #{single_branch} #{depth} #{repo} #{path}"
39
47
  Dir.chdir path
40
48
  exec "git checkout #{version}"
41
49
  end
@@ -43,14 +51,6 @@ module Docman
43
51
  result
44
52
  end
45
53
 
46
- def self.read_yaml_from_file(repo, path, version, filename)
47
- self.get(repo, path, 'branch', version)
48
- filepath = File.join(path, filename)
49
- return YAML::load_file(filepath) if File.file? filepath
50
- nil
51
- rescue StandardError => e
52
- raise "Error in info file: #{filepath}, #{e.message}"
53
- end
54
54
 
55
55
  def self.last_revision
56
56
  result = `git rev-parse --short HEAD`
@@ -21,7 +21,7 @@ module Docman
21
21
  if state.has_key?('source')
22
22
  if state['source']['type'] == :retrieve_from_repo
23
23
  repo = state['source']['repo'] == :project_repo ? self['repo'] : state['source']['repo']
24
- external_state_info = GitUtil.read_yaml_from_file(repo, self['temp_path'], state['source']['branch'], state['source']['file'])
24
+ external_state_info = read_yaml_from_file(repo, self['temp_path'], state['source']['branch'], state['source']['file'])
25
25
  state.deep_merge! external_state_info
26
26
  end
27
27
  end
@@ -29,6 +29,15 @@ module Docman
29
29
  end
30
30
  end
31
31
 
32
+ def read_yaml_from_file(repo, path, version, filename)
33
+ GitUtil.get(repo, path, 'branch', version, nil, nil, need_rebuild?)
34
+ filepath = File.join(path, filename)
35
+ return YAML::load_file(filepath) if File.file? filepath
36
+ nil
37
+ rescue StandardError => e
38
+ raise "Error in info file: #{filepath}, #{e.message}"
39
+ end
40
+
32
41
  def version
33
42
  state.nil? ? nil : state['version']
34
43
  end
@@ -1,3 +1,3 @@
1
1
  module Docman
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
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.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Tolstikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-21 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler