git-deploy 0.3.0 → 0.4.0

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.
data/lib/git_deploy.rb CHANGED
@@ -75,8 +75,8 @@ Capistrano::Configuration.instance(true).load do
75
75
 
76
76
  command = ["#{try_sudo} mkdir -p #{deploy_to}"]
77
77
  command << "#{try_sudo} chown $USER #{deploy_to}" if :sudo == run_method
78
+ command << "chmod g+ws #{deploy_to}" if shared
78
79
  command << "cd #{deploy_to}"
79
- command << "chmod g+w ." if shared
80
80
  command << "git init #{shared ? '--shared' : ''}"
81
81
  command << "sed -i'' -e 's/master/#{branch}/' .git/HEAD" unless branch == 'master'
82
82
  command << "git config --bool receive.denyNonFastForwards false" if shared
@@ -7,10 +7,14 @@ if ENV['GIT_DIR'] == '.'
7
7
  ENV['GIT_DIR'] = '.git'
8
8
  end
9
9
 
10
+ cmd = %(bash -c "[ -f /etc/profile ] && source /etc/profile; echo $PATH")
11
+ envpath = IO.popen(cmd, 'r') { |io| io.read.chomp }
12
+ ENV['PATH'] = envpath
13
+
10
14
  # find out the current branch
11
- head = File.read('.git/HEAD').chomp
15
+ head = `git symbolic-ref HEAD`.chomp
12
16
  # abort if we're on a detached head
13
- exit unless head.sub!('ref: ', '')
17
+ exit unless $?.success?
14
18
 
15
19
  oldrev = newrev = nil
16
20
  null_ref = '0' * 40
@@ -26,13 +30,19 @@ end
26
30
  exit if newrev.nil? or newrev == null_ref
27
31
 
28
32
  # update the working copy
29
- `git reset --hard`
33
+ `umask 002 && git reset --hard`
34
+
35
+ config = 'config/database.yml'
36
+ logfile = 'log/deploy.log'
37
+ restart = 'tmp/restart.txt'
30
38
 
31
39
  if oldrev == null_ref
32
40
  # this is the first push; this branch was just created
33
41
  require 'fileutils'
34
42
  FileUtils.mkdir_p %w(log tmp)
35
- config = 'config/database.yml'
43
+ FileUtils.chmod 0775, %w(log tmp)
44
+ FileUtils.touch [logfile, restart]
45
+ FileUtils.chmod 0664, [logfile, restart]
36
46
 
37
47
  unless File.exists?(config)
38
48
  # install the database config from the example file
@@ -40,7 +50,6 @@ if oldrev == null_ref
40
50
  FileUtils.cp example, config if example
41
51
  end
42
52
  else
43
- logfile = 'log/deploy.log'
44
53
  # log timestamp
45
54
  File.open(logfile, 'a') { |log| log.puts "==== #{Time.now} ====" }
46
55
  # start the post-reset hook in background
@@ -68,12 +68,12 @@ end
68
68
 
69
69
  # run migrations when new ones added
70
70
  if new_migrations = added_files.any_in_dir?('db/migrate')
71
- system %(rake db:migrate RAILS_ENV=#{RAILS_ENV})
71
+ system %(umask 002 && rake db:migrate RAILS_ENV=#{RAILS_ENV})
72
72
  end
73
73
 
74
74
  if modified_files.include?('.gitmodules')
75
75
  # initialize new submodules
76
- system %(git submodule init)
76
+ system %(umask 002 && git submodule init)
77
77
  # sync submodule remote urls in case of changes
78
78
  config = parse_configuration('.gitmodules')
79
79
 
@@ -96,13 +96,19 @@ if modified_files.include?('.gitmodules')
96
96
  end
97
97
  end
98
98
  # update existing submodules
99
- system %(git submodule update)
99
+ system %(umask 002 && git submodule update)
100
+
101
+ if changed_files.include?('Gemfile')
102
+ # update bundled gems if manifest file has changed
103
+ system %(umask 002 && bundle install)
104
+ end
100
105
 
101
106
  # clean unversioned files from vendor (e.g. old submodules)
102
107
  system %(git clean -d -f vendor)
103
108
 
104
109
  # determine if app restart is needed
105
- if cached_assets_cleared or new_migrations or changed_files.any_in_dir?(%w(app config lib public vendor))
110
+ if cached_assets_cleared or new_migrations or !File.exists?('config/environment.rb') or
111
+ changed_files.any_in_dir?(%w(app config lib public vendor))
106
112
  require 'fileutils'
107
113
  # tell Passenger to restart this app
108
114
  FileUtils.touch 'tmp/restart.txt'
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 4
8
+ - 0
9
+ version: 0.4.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - "Mislav Marohni\xC4\x87"
@@ -9,19 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-11-25 00:00:00 +01:00
17
+ date: 2010-04-11 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: capistrano
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ~>
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 5
30
+ - 9
23
31
  version: 2.5.9
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  description: A tool to install useful git hooks on your remote repository to enable push-based, Heroku-like deployment on your host.
26
35
  email: mislav.marohnic@gmail.com
27
36
  executables: []
@@ -36,7 +45,7 @@ files:
36
45
  - lib/hooks/post-reset.rb
37
46
  - README.markdown
38
47
  - LICENSE
39
- has_rdoc: false
48
+ has_rdoc: true
40
49
  homepage: http://github.com/mislav/git-deploy
41
50
  licenses: []
42
51
 
@@ -49,18 +58,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
58
  requirements:
50
59
  - - ">="
51
60
  - !ruby/object:Gem::Version
61
+ segments:
62
+ - 0
52
63
  version: "0"
53
- version:
54
64
  required_rubygems_version: !ruby/object:Gem::Requirement
55
65
  requirements:
56
66
  - - ">="
57
67
  - !ruby/object:Gem::Version
68
+ segments:
69
+ - 0
58
70
  version: "0"
59
- version:
60
71
  requirements: []
61
72
 
62
73
  rubyforge_project:
63
- rubygems_version: 1.3.5
74
+ rubygems_version: 1.3.6
64
75
  signing_key:
65
76
  specification_version: 3
66
77
  summary: Simple git push-based application deployment