docman 0.0.13 → 0.0.14
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/features/git_target/git_target.feature +20 -0
- data/lib/application.rb +2 -1
- data/lib/docman/builders/builder.rb +12 -4
- data/lib/docman/builders/drupal_drush_builder.rb +2 -1
- data/lib/docman/builders/git_direct_builder.rb +3 -2
- data/lib/docman/builders/git_strip_builder.rb +1 -1
- data/lib/docman/commands/command.rb +1 -1
- data/lib/docman/commands/git_commit_cmd.rb +1 -2
- data/lib/docman/config.rb +4 -1
- data/lib/docman/deployers/deployer.rb +5 -4
- data/lib/docman/git_util.rb +13 -4
- data/lib/docman/info.rb +16 -3
- data/lib/docman/version.rb +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: 0fb73f66842f33cfed8718d90967ff300c9003df
|
4
|
+
data.tar.gz: 1a7ab11302d11b040020666a2cdcf03764c24937
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f195b9bcca8313fac8986eaa236e7125263740178b7a59779c2fe9c028ccb309ca652f75e3474ea1bdf059346df78a75596699d93f6bcf55429fd99c35e4a4ec
|
7
|
+
data.tar.gz: 6d219e4d86dfb1f2afd051e9951607a4ee98cc8fbd66737aa9d3bb7d1c9cbb00dc63443cdee35b20bb6066aed98b9e135b24296cf2269034de302b3d3b86f6d7
|
@@ -63,3 +63,23 @@ Feature: Docroot management - git_target
|
|
63
63
|
| master/profiles/sample_profile |
|
64
64
|
| master/projects/sample_project1 |
|
65
65
|
| master/projects/sample_project2 |
|
66
|
+
|
67
|
+
@announce
|
68
|
+
@no-clobber
|
69
|
+
@git_target
|
70
|
+
@master
|
71
|
+
@deploy
|
72
|
+
@sites
|
73
|
+
Scenario: git_target deploy sites master
|
74
|
+
Given I cd to "sample-docroot"
|
75
|
+
Then I run `docman deploy git_target sites branch master`
|
76
|
+
Then the exit status should be 0
|
77
|
+
Then the following directories should exist:
|
78
|
+
| master |
|
79
|
+
| master/docroot |
|
80
|
+
| master/docroot/sites |
|
81
|
+
| master/hooks |
|
82
|
+
| master/profiles |
|
83
|
+
| master/profiles/sample_profile |
|
84
|
+
| master/projects/sample_project1 |
|
85
|
+
| master/projects/sample_project2 |
|
data/lib/application.rb
CHANGED
@@ -57,6 +57,7 @@ module Docman
|
|
57
57
|
def deploy(deploy_target_name, name, type, version, options = false)
|
58
58
|
@options = options
|
59
59
|
@deploy_target = @config['deploy_targets'][deploy_target_name]
|
60
|
+
raise "Wrong deploy target: #{deploy_target_name}" if @deploy_target.nil?
|
60
61
|
@deploy_target['name'] = deploy_target_name
|
61
62
|
@docroot_config = DocrootConfig.new(@workspace_dir, deploy_target)
|
62
63
|
@docroot_config.states_dependin_on(name, version).keys.each do |state|
|
@@ -65,7 +66,7 @@ module Docman
|
|
65
66
|
end
|
66
67
|
|
67
68
|
def execute(action, state, name = nil)
|
68
|
-
params = @deploy_target
|
69
|
+
params = Marshal.load(Marshal.dump(@deploy_target))
|
69
70
|
params['state'] = state
|
70
71
|
params['action'] = action
|
71
72
|
params['name'] = name
|
@@ -32,16 +32,24 @@ module Docman
|
|
32
32
|
|
33
33
|
before_execute do
|
34
34
|
if @context.need_rebuild?
|
35
|
-
|
35
|
+
@context.build_mode = :rebuild
|
36
36
|
else
|
37
|
-
|
38
|
-
|
37
|
+
if @context.changed? or changed?
|
38
|
+
@context.build_mode = :update
|
39
|
+
log("Changed")
|
40
|
+
else
|
41
|
+
log("Not changed")
|
42
|
+
@context.build_mode = :none
|
43
|
+
raise NoChangesError, 'This version already deployed'
|
44
|
+
end
|
39
45
|
end
|
40
46
|
|
41
47
|
end
|
42
48
|
|
43
49
|
after_execute do
|
44
|
-
|
50
|
+
if @execute_result
|
51
|
+
@execute_result = @context.write_info(@execute_result)
|
52
|
+
end
|
45
53
|
end
|
46
54
|
|
47
55
|
def changed?
|
@@ -7,7 +7,8 @@ module Docman
|
|
7
7
|
register_builder :drupal_drush_builder
|
8
8
|
|
9
9
|
def execute
|
10
|
-
return
|
10
|
+
return if @build_mode == :none
|
11
|
+
#return unless @context.need_rebuild?
|
11
12
|
puts 'Download drupal through drush'
|
12
13
|
FileUtils.mkdir_p(@context['temp_path'])
|
13
14
|
Dir.chdir @context['temp_path']
|
@@ -7,13 +7,14 @@ module Docman
|
|
7
7
|
def execute
|
8
8
|
execute_result = GitUtil.get(@context['repo'], @context['full_build_path'], @context.version_type, @context.version)
|
9
9
|
# No commit hash for 'root' as it will be changed later
|
10
|
-
@context['type'] == 'root' ? @context['build_path'] : execute_result
|
10
|
+
result = @context['type'] == 'root' ? @context['build_path'] : execute_result
|
11
|
+
GitUtil.repo_changed?(@context['full_build_path']) ? result : false
|
11
12
|
end
|
12
13
|
|
13
14
|
def changed?
|
14
15
|
stored_version = @context.stored_version['result']
|
15
16
|
# No commit hash for 'root' as it will be changed later
|
16
|
-
repo_version = @context['type'] == 'root' ? @context['build_path'] : GitUtil.get(@context['repo'], @context['full_build_path'], @context.version_type, @context.version)
|
17
|
+
repo_version = @context['type'] == 'root' ? @context['build_path'] : GitUtil.get(@context['repo'], @context['full_build_path'], @context.version_type, @context.version, true)
|
17
18
|
stored_version != repo_version
|
18
19
|
end
|
19
20
|
|
@@ -11,7 +11,7 @@ module Docman
|
|
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'))
|
14
|
-
result
|
14
|
+
GitUtil.repo_changed?(@context['full_build_path']) ? result : false
|
15
15
|
end
|
16
16
|
|
17
17
|
def changed?
|
@@ -50,7 +50,7 @@ module Docman
|
|
50
50
|
def add_actions(obj, context = nil)
|
51
51
|
if obj.has_key? 'hooks' and obj['hooks'].has_key? @type
|
52
52
|
obj['hooks'][@type].each_pair do |name, hooks|
|
53
|
-
hooks = hooks
|
53
|
+
hooks = Marshal::load(Marshal.dump(hooks))
|
54
54
|
unless context.nil?
|
55
55
|
hooks.each do |hook|
|
56
56
|
hook['context'] = context
|
@@ -10,9 +10,8 @@ module Docman
|
|
10
10
|
|
11
11
|
before_execute do
|
12
12
|
unless GitUtil.repo_changed? @context['root']['full_build_path']
|
13
|
-
raise NoChangesError, "Repo not changed
|
13
|
+
raise NoChangesError, "Repo not changed, commit not needed" unless @context.need_rebuild?
|
14
14
|
end
|
15
|
-
# @not_execute = true unless GitUtil.repo_changed? @context['root']['full_build_path']
|
16
15
|
end
|
17
16
|
|
18
17
|
def execute
|
data/lib/docman/config.rb
CHANGED
@@ -5,6 +5,8 @@ require 'digest/md5'
|
|
5
5
|
module Docman
|
6
6
|
class Config < Hash
|
7
7
|
|
8
|
+
attr_reader :unmutable_config
|
9
|
+
|
8
10
|
def initialize(file)
|
9
11
|
super
|
10
12
|
@config = YAML::load_file(file)
|
@@ -15,6 +17,7 @@ module Docman
|
|
15
17
|
@config.each_pair do |k, v|
|
16
18
|
self[k] = v
|
17
19
|
end
|
20
|
+
@unmutable_config = Marshal::load(Marshal.dump(@config))
|
18
21
|
end
|
19
22
|
|
20
23
|
def merge_config_from_file(file)
|
@@ -24,7 +27,7 @@ module Docman
|
|
24
27
|
end
|
25
28
|
|
26
29
|
def config_hash
|
27
|
-
Digest::MD5.hexdigest(Marshal::dump(
|
30
|
+
Digest::MD5.hexdigest(Marshal::dump(@unmutable_config))
|
28
31
|
end
|
29
32
|
|
30
33
|
end
|
@@ -53,7 +53,7 @@ module Docman
|
|
53
53
|
|
54
54
|
stored_config_hash = read_version_file_param('config_hash')
|
55
55
|
@config_hash = Docman::Application.instance.config.config_hash
|
56
|
-
@config_yaml = Docman::Application.instance.config.to_yaml
|
56
|
+
@config_yaml = Docman::Application.instance.config.unmutable_config.to_yaml
|
57
57
|
|
58
58
|
#TODO: need to refactor
|
59
59
|
stored_docroot_config_hash = read_version_file_param('docroot_config_hash')
|
@@ -66,7 +66,7 @@ module Docman
|
|
66
66
|
Docman::Application.instance.force = true
|
67
67
|
end
|
68
68
|
if stored_docroot_config_hash != @docroot_config_hash
|
69
|
-
log 'Forced rebuild as configuration was changed', 'info'
|
69
|
+
log 'Forced rebuild as docroot configuration was changed', 'info'
|
70
70
|
filename = File.join(@docroot_config.root['full_build_path'], 'docroot_config.yaml')
|
71
71
|
log Diffy::Diff.new(read_file(filename), @docroot_config_yaml) if File.file? filename
|
72
72
|
Docman::Application.instance.force = true
|
@@ -105,7 +105,8 @@ module Docman
|
|
105
105
|
def read_file(path)
|
106
106
|
YAML::load_file(path)
|
107
107
|
rescue
|
108
|
-
|
108
|
+
log "Error in config file #{path}"
|
109
|
+
return false
|
109
110
|
end
|
110
111
|
|
111
112
|
def read_version_file_param(param)
|
@@ -124,7 +125,7 @@ module Docman
|
|
124
125
|
end
|
125
126
|
|
126
127
|
def write_config_file(config, path)
|
127
|
-
File.open(path, 'w') {|f| f.write config
|
128
|
+
File.open(path, 'w') {|f| f.write config}
|
128
129
|
end
|
129
130
|
|
130
131
|
def build
|
data/lib/docman/git_util.rb
CHANGED
@@ -20,28 +20,37 @@ 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, force_return = false)
|
24
24
|
if File.directory? path and File.directory?(File.join(path, '.git'))
|
25
25
|
Dir.chdir path
|
26
26
|
|
27
|
-
self.reset_repo(path) if self.repo_changed?(path)
|
27
|
+
self.reset_repo(path) #if self.repo_changed?(path)
|
28
28
|
|
29
29
|
if type == 'branch'
|
30
30
|
exec "git checkout #{version}"
|
31
|
+
initial_revision = self.last_revision
|
31
32
|
exec "git pull origin #{version}"
|
32
33
|
end
|
33
34
|
if type == 'tag'
|
34
35
|
exec 'git fetch --tags'
|
36
|
+
initial_revision = self.last_revision
|
35
37
|
exec "git checkout tags/#{version}"
|
36
38
|
end
|
37
39
|
else
|
40
|
+
initial_revision = nil
|
38
41
|
FileUtils.rm_rf path if File.directory? path
|
39
42
|
exec "git clone #{repo} #{path}"
|
40
43
|
Dir.chdir path
|
41
44
|
exec "git checkout #{version}"
|
42
45
|
end
|
43
|
-
result =
|
46
|
+
result = self.last_revision
|
44
47
|
@logger.info "Commit hash: #{result}"
|
48
|
+
# force_return or result != initial_revision ? result : false
|
49
|
+
result
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.last_revision
|
53
|
+
result = `git rev-parse --short HEAD`
|
45
54
|
result.delete!("\n")
|
46
55
|
end
|
47
56
|
|
@@ -54,7 +63,7 @@ module Docman
|
|
54
63
|
# puts message
|
55
64
|
pull root_path
|
56
65
|
exec %Q(git add --all #{path.slice "#{root_path}/"})
|
57
|
-
exec %Q(git commit -m "#{message}")
|
66
|
+
exec %Q(git commit -m "#{message}") if repo_changed? path
|
58
67
|
end
|
59
68
|
end
|
60
69
|
|
data/lib/docman/info.rb
CHANGED
@@ -5,7 +5,7 @@ module Docman
|
|
5
5
|
|
6
6
|
include Docman::Context
|
7
7
|
|
8
|
-
attr_accessor :need_rebuild
|
8
|
+
attr_accessor :need_rebuild, :build_mode
|
9
9
|
|
10
10
|
def initialize(hash = {})
|
11
11
|
super
|
@@ -14,6 +14,7 @@ module Docman
|
|
14
14
|
end
|
15
15
|
self['build_type'] = self['docroot_config'].deploy_target['builders'][self['type']]['handler']
|
16
16
|
@need_rebuild = Hash.new
|
17
|
+
@changed = Hash.new
|
17
18
|
end
|
18
19
|
|
19
20
|
def version
|
@@ -41,6 +42,16 @@ module Docman
|
|
41
42
|
to_save
|
42
43
|
end
|
43
44
|
|
45
|
+
def changed?
|
46
|
+
#TODO: need refactor
|
47
|
+
return @changed[self['state']] if not @changed.nil? and @changed.has_key? self['state'] and not @changed[self['state']].nil?
|
48
|
+
@changed[self['state']] = false
|
49
|
+
if need_rebuild?
|
50
|
+
@changed[self['state']] = true
|
51
|
+
end
|
52
|
+
@changed[self['state']]
|
53
|
+
end
|
54
|
+
|
44
55
|
def need_rebuild?
|
45
56
|
return @need_rebuild[self['state']] if not @need_rebuild.nil? and @need_rebuild.has_key? self['state'] and not @need_rebuild[self['state']].nil?
|
46
57
|
@need_rebuild[self['state']] = _need_rebuild?
|
@@ -66,10 +77,12 @@ module Docman
|
|
66
77
|
return true unless v
|
67
78
|
return true if v['type'] != self['type']
|
68
79
|
return true if v['build_type'] != self['build_type']
|
69
|
-
return true if (not v['version'].nil? and v['version'] != self.version)
|
80
|
+
# return true if (not v['version'].nil? and v['version'] != self.version)
|
81
|
+
@changed[self['state']] = true if (not v['version'].nil? and v['version'] != self.version)
|
70
82
|
return true if (not v['version_type'].nil? and v['version_type'] != self.version_type)
|
71
83
|
unless v['state'].nil?
|
72
|
-
return true if v['state'] != self['state']
|
84
|
+
# return true if v['state'] != self['state']
|
85
|
+
@changed[self['state']] = true if v['state'] != self['state']
|
73
86
|
end
|
74
87
|
false
|
75
88
|
end
|
data/lib/docman/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.14
|
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-
|
11
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|