capistrano-gity 0.5.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2I2ZTA0OTg3NWRiYzMxYjNhYmE2ZTRhNDhmODhiMzY5YTFlYjg1Zg==
4
+ YWZhZWNlMDNjMjhhODJjZjZiNGIzN2Q1OGM3MWIzNzAyMzUyY2Y2ZQ==
5
5
  data.tar.gz: !binary |-
6
- ZmJmN2I0YjVkYTcyNGYyNjY5NTEzN2RlZGI2MDlhNmZlMzBlYzk5Yg==
6
+ YTVmNTExMDEyYTllMDcxNDg1MDVkZWZkOTI5OWU3MDcxY2EyYzNmYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDczNDYxY2UzNGUwNzhmZTRmMGIxYjJhZDUzYTY5OTI1NjhkZmIxMWQxMTU0
10
- NGEwM2UzYjBiZTA3Zjc5NGUyZDkyOTcyMDMxNGI4MGY3MTNmMTVhMWQxMzRh
11
- MWU5YmE4OWQxNmExNzQ0MjMzZjA5OGYxY2Q0MzQwNDBmZTQzNjQ=
9
+ YjFkOWZkNmFjYjUzNmQxOWU2ZGU2ODQwMDA0NzY4MzgxN2VkMTU5ZTFmMWNk
10
+ Mzc2OWY3ZmZkNTJiZjBjY2M4OGMzYTQ0ODY5ZjIzOTE5NDgyM2E0MDI4OTZl
11
+ Njg4MzgwODcwYjQwYmVkM2Q3NjhjNTE0Y2ZiZDJkMThjMjJhMWU=
12
12
  data.tar.gz: !binary |-
13
- MmExZTA1NWY1ZTgwOTZkY2Q2NThhNGNiNWZiN2I2OGZhZGZiYTQwZDBmOWRi
14
- YmQ2Y2UwYWE2M2Q1MjIzNDM5N2VlZDUxYTU4MzZmYWY3YmI1Nzg2NmY5YTE0
15
- Y2I3ZDZmZmQ2MjZmY2I3N2U3MDgzYWFlZGE3ZjViZmU2MThkOWM=
13
+ Mzg5MmM2OTM1MWVkOWYwYTU2NGE3ZjgwYjYzYTYxYzE2MGYxZjc0MzI0ZDAz
14
+ ZTJjMTNhZTU5N2FhMjNiZjMyY2Y4YmZiMjRmMzdiYjU2ZmQ3MjE4ZGM2NjBi
15
+ NTAyZWI1ZjMzODE3NDU5OWNmNjlhMTU5Yjk2MzU3MWZjZDM1ZDc=
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # Capistrano::Gity
2
+
3
+ Git deployment helpers for Capistrano v3.
4
+
5
+ #Installation
6
+
7
+ Add this in your Gemfile:
8
+
9
+ ```ruby
10
+ gem 'capistrano', '~> 3.1'
11
+ gem 'capistrano-gity', '~> 0.6.0'
12
+ ```
13
+
14
+ # Usage
15
+
16
+ Require in `Capfile` to use gity as a wrapper of capistrano:deploy task:
17
+
18
+ ```ruby
19
+ require 'capistrano/gity'
20
+ ```
21
+
22
+ The task `gity:prepare_deploy` runs before `deploy:starting` and creates a remote temp branch under `remote/deploy/`.
23
+
24
+ Use the following to delete the temporary branch after successfull deployment,
25
+ i.e. after `deploy:finished`:
26
+
27
+ ```ruby
28
+ set :auto_cleanup, true
29
+ ```
30
+
31
+ You can also change the default temporary branch prefix, i.e. `deploy/` with:
32
+
33
+ ```ruby
34
+ set :branch_prefix, 'deploy/production/'
35
+ ```
36
+
37
+ # Useful tasks
38
+
39
+ ```sh
40
+ bundle exec cap production gity:help
41
+ bundle exec cap production gity:check
42
+ bundle exec cap production gity:uptip
43
+ bundle exec cap production gity:cleanup_temp_branches
44
+ ```
45
+
46
+ Check the module for details :)
47
+
48
+ ## Contributing
49
+
50
+ 1. Fork the project
51
+ 2. Make your feature addition or bug fix
52
+ 3. Create new Pull Request
@@ -1,35 +1,20 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
2
4
 
3
5
  Gem::Specification.new do |s|
4
- s.name = "capistrano-gity"
5
- s.version = "0.5.1"
6
+ s.name = 'capistrano-gity'
7
+ s.version = '1.0.0'
8
+ s.authors = ['Skroutz.gr Team']
9
+ s.date = '2012-05-21'
10
+ s.email = 'yatiohi@ideopolis.gr'
11
+ s.extra_rdoc_files = ['LICENSE', 'README.md']
12
+ s.files = `git ls-files`.split($/)
13
+ s.homepage = 'http://github.com/ctrochalakis/capistrano-gity'
14
+ s.require_paths = ['lib']
15
+ s.rubygems_version = '1.8.11'
16
+ s.summary = 'Git helpers for Capistrano v3 deployments'
6
17
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Skroutz.gr Team"]
9
- s.date = "2012-05-21"
10
- s.email = "yatiohi@ideopolis.gr"
11
- s.extra_rdoc_files = [
12
- "LICENSE",
13
- "README.rdoc"
14
- ]
15
- s.files = [
16
- "LICENSE",
17
- "README.rdoc",
18
- "capistrano-gity.gemspec",
19
- "lib/capistrano-gity.rb"
20
- ]
21
- s.homepage = "http://github.com/ctrochalakis/capistrano-gity"
22
- s.require_paths = ["lib"]
23
- s.rubygems_version = "1.8.11"
24
- s.summary = "Git helpers for capistrano deployments"
25
-
26
- if s.respond_to? :specification_version then
27
- s.specification_version = 3
28
-
29
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
30
- else
31
- end
32
- else
33
- end
18
+ s.add_dependency 'capistrano', '~> 3.1'
19
+ s.add_dependency 'sshkit', '~> 1.2'
34
20
  end
35
-
@@ -0,0 +1 @@
1
+ load File.expand_path('../tasks/gity.cap', __FILE__)
@@ -0,0 +1,161 @@
1
+ namespace :gity do
2
+ desc 'Show revision and upstream '
3
+ task :check do
4
+ invoke 'gity:uprev'
5
+ invoke 'gity:uptip'
6
+ end
7
+
8
+ desc 'Delete temp branch if auto_cleanup is set to true'
9
+ task :cleanup_deploy do
10
+ if fetch(:auto_cleanup)
11
+ run_locally do
12
+ system "git push #{fetch(:remote)} --delete --quiet #{fetch(:branch)}"
13
+ end
14
+ end
15
+ end
16
+
17
+ desc 'Delete all remote temporary branches, i.e. under deploy/'
18
+ task :cleanup_temp_branches do
19
+ run_locally do
20
+ system "git ls-remote --heads #{fetch(:remote)} '#{fetch(:branch_prefix)}*' | awk '{print $2}' | xargs git push #{fetch(:remote)} --quiet --delete"
21
+ end
22
+ end
23
+
24
+ desc 'Create temporary branch on remote'
25
+ task :create_temp_branch do
26
+ run_locally do
27
+ system "git push --force --quiet #{fetch(:remote)} HEAD:#{fetch(:branch)}"
28
+ end
29
+ end
30
+
31
+ desc 'A small overview of the deployment procedure'
32
+ task :help do
33
+ puts <<-HELP
34
+
35
+ Overview:
36
+ * Deploying the #{fetch(:branch)} branch of #{fetch(:repo_url)}
37
+ * The #{fetch(:branch)} branch can be moved *anywhere*.
38
+
39
+ Quick help:
40
+ * Checkout the branch you want to mark as #{fetch(:live_branch)}
41
+ (ex. master) and run:cap deploy
42
+
43
+ Under the hood:
44
+ * git push --force #{fetch(:remote)} HEAD:#{fetch(:branch)} (or cap gity:create_temp_branch)
45
+ * git push --force #{fetch(:remote)} HEAD:#{fetch(:live_branch)} (or cap gity:push_to_live)
46
+ * cap deploy
47
+
48
+ Troubleshooting:
49
+ cap gity:uptip # Show the #{fetch(:live_branch)} branch of the central repo
50
+ cap gity:status # A log-like view showing important commits
51
+
52
+ cap gity:check # check consistency between the applied revision and the one on the #{fetch(:live_branch)} branch
53
+ HELP
54
+ end
55
+
56
+ desc 'Do necessary steps before deployment'
57
+ task :prepare_deploy do
58
+ invoke 'gity:sync'
59
+ exit 127 if quit?
60
+ invoke 'gity:create_temp_branch'
61
+ end
62
+
63
+ desc 'Push HEAD to the central repo'
64
+ task :push do
65
+ run_locally do
66
+ system "git push --force --quiet #{fetch(:remote)} HEAD:#{fetch(:live_branch)}"
67
+ end
68
+ end
69
+
70
+ desc 'Push temporary branch to live branch'
71
+ task :push_to_live do
72
+ invoke 'gity:push'
73
+ invoke 'gity:uptip'
74
+ end
75
+
76
+ desc 'View a graph log of the commits usually involved in a deployment'
77
+ task :status do
78
+ run_locally do
79
+ puts "\nOverview (we are deploying origin/#{fetch(:live_branch)})"
80
+
81
+ invoke 'gity:sync'
82
+
83
+ system "git --no-pager log --decorate --graph --oneline #{fetch(:remote)}/#{fetch(:live_branch)} #{fetch(:remote)}/master --not #{fetch(:remote)}/#{fetch(:live_branch)}^@ --"
84
+ end
85
+ end
86
+
87
+ desc 'Fetch remote'
88
+ task :sync do
89
+ run_locally do
90
+ system "git fetch #{fetch(:remote)}"
91
+ end
92
+ end
93
+
94
+ desc 'Diplay current revision'
95
+ task :uprev do
96
+ on release_roles(:app) do
97
+ within "#{current_path}" do
98
+ execute "cd #{current_path} && cat REVISION"
99
+ end
100
+ end
101
+ end
102
+
103
+ desc 'Display where the central live branch is pointing'
104
+ task :uptip do
105
+ run_locally do
106
+ system %(git --no-pager log --decorate -1 --format="#{fetch(:remote)}'s #{fetch(:live_branch)} tip is set to: [%h] %s (%an, %ar)" #{fetch(:remote)}/#{fetch(:live_branch)})
107
+ end
108
+ end
109
+
110
+ def quit?
111
+ return false if !fetch(:check_master)
112
+
113
+ upstream_master = `git rev-parse #{fetch(:remote)}/master`
114
+ commit_id = fetch(:commit_id)
115
+ if commit_id != upstream_master
116
+ puts <<-MSG
117
+ The commit(#{commit_id}) you are pushing is different from #{fetch(:remote)} master.
118
+ This means that a subsequent deploy might not include your work.
119
+ Consider pushing to master now or later.
120
+ MSG
121
+ set :answer, ask('Do you want to continue? (y/n)', 'n')
122
+ return !fetch(:answer).downcase.start_with?('y')
123
+ end
124
+ return false
125
+ end
126
+
127
+ before 'deploy:starting', 'gity:prepare_deploy'
128
+ after 'deploy:finished', 'gity:push_to_live'
129
+ after 'deploy:finished', 'gity:cleanup_deploy'
130
+ end
131
+
132
+ namespace :load do
133
+ task :defaults do
134
+ set :auto_cleanup, false
135
+ set :branch_prefix, 'deploy/'
136
+ set :commit_id, -> { `git rev-parse --short HEAD`.chomp }
137
+ set :branch, -> {
138
+ "#{fetch(:branch_prefix)}#{Time.now.strftime('%Y%m%d_%H%M%S')}_#{fetch(:commit_id)}"
139
+ }
140
+
141
+ # Most people use origin here
142
+ unless any?(:remote)
143
+ git_remote = `git config deploy.remote`.strip
144
+
145
+ set :remote, git_remote.empty? ? 'origin' : git_remote
146
+ end
147
+
148
+ unless any?(:check_master)
149
+ check_master = case `git config deploy.check-master`.strip
150
+ when 'false', 'f', '0'
151
+ false
152
+ when 'true', 't', '1'
153
+ true
154
+ else
155
+ true
156
+ end
157
+
158
+ set :check_master, check_master
159
+ end
160
+ end
161
+ end
@@ -1,105 +0,0 @@
1
- Capistrano::Configuration.instance.load do
2
- namespace :gity do
3
-
4
- # Most people use origin here
5
- unless exists?(:remote)
6
- git_remote = `git config deploy.remote`.strip
7
- set :remote, git_remote.empty? ? 'origin' : git_remote
8
- end
9
-
10
- unless exists?(:check_master)
11
- check_master = case `git config deploy.check-master`.strip
12
- when 'false', 'f', '0'
13
- false
14
- when 'true', 't', '1'
15
- true
16
- else
17
- true
18
- end
19
-
20
- set :check_master, check_master
21
- end
22
-
23
- desc "Push HEAD to the central repo"
24
- task :push do
25
- system "git push --force #{remote} HEAD:#{branch}"
26
- end
27
-
28
- task :sync do
29
- system "git fetch #{remote}"
30
- end
31
-
32
- desc "View a graph log of the commits usually involved in a deployment"
33
- task :status do
34
- puts "\nOverview (we are deploying origin/#{branch})"
35
- sync
36
- system "git --no-pager log --decorate --graph --oneline #{remote}/#{branch} #{remote}/master --not #{remote}/#{branch}^@ --"
37
- end
38
-
39
- desc "Display where the central live branch is pointing"
40
- task :uptip do
41
- sync
42
- system %(git --no-pager log --decorate -1 --format="#{remote}'s #{branch} tip is set to: [%h] %s (%an, %ar)" #{remote}/#{branch})
43
- end
44
-
45
- desc "A small overview of the deployment procedure"
46
- task :help do
47
- puts <<-HELP
48
-
49
- Overview:
50
- * Deploying the #{branch} branch of #{repository}
51
- * The #{branch} branch can be moved *anywhere*.
52
-
53
- Quick help:
54
- Go the branch you want to mark as #{branch} (ex. master) and run:
55
- cap deploy
56
-
57
- Under the hood:
58
- * git push --force #{remote} HEAD:#{branch} (or cap gity:push)
59
- * cap deploy
60
-
61
- Troubleshooting:
62
- cap gity:uptip # Show the #{branch} branch of the central repo
63
- cap gity:status # A log-like view showing important commits
64
-
65
- cap gity:check # check consistency between the applied revision and the one on the #{branch} branch
66
- HELP
67
- end
68
-
69
- task :uprev do
70
- run "cd #{current_path} && cat REVISION"
71
- end
72
-
73
- task :check do
74
- uprev
75
- uptip
76
- end
77
-
78
- def quit?
79
- return false if !check_master
80
-
81
- upstream_master = `git rev-parse #{remote}/master`
82
- here = `git rev-parse HEAD`
83
- if here != upstream_master
84
- puts <<-MSG
85
- The commit you are pushing is different from #{remote} master.
86
- This means that a subsequent deploy might not include your work.
87
- Consider pushing to master now or later.
88
- MSG
89
- answer = Capistrano::CLI.ui.ask("Do you want to continue? (y/n)")
90
- return !answer.downcase.start_with?('y')
91
- end
92
- return false
93
- end
94
-
95
- task :prepare_deploy do
96
- sync
97
- exit 127 if quit?
98
- push
99
- uptip
100
- end
101
-
102
- before 'deploy:update_code', 'gity:prepare_deploy'
103
-
104
- end
105
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-gity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skroutz.gr Team
@@ -9,19 +9,50 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2012-05-21 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ~>
17
+ - !ruby/object:Gem::Version
18
+ version: '3.1'
19
+ prerelease: false
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: '3.1'
25
+ name: capistrano
26
+ type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.2'
33
+ prerelease: false
34
+ version_requirements: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '1.2'
39
+ name: sshkit
40
+ type: :runtime
13
41
  description:
14
42
  email: yatiohi@ideopolis.gr
15
43
  executables: []
16
44
  extensions: []
17
45
  extra_rdoc_files:
18
46
  - LICENSE
19
- - README.rdoc
47
+ - README.md
20
48
  files:
49
+ - .gitignore
21
50
  - LICENSE
22
- - README.rdoc
51
+ - README.md
23
52
  - capistrano-gity.gemspec
24
53
  - lib/capistrano-gity.rb
54
+ - lib/capistrano/gity.rb
55
+ - lib/capistrano/tasks/gity.cap
25
56
  homepage: http://github.com/ctrochalakis/capistrano-gity
26
57
  licenses: []
27
58
  metadata: {}
@@ -43,7 +74,7 @@ requirements: []
43
74
  rubyforge_project:
44
75
  rubygems_version: 2.1.11
45
76
  signing_key:
46
- specification_version: 3
47
- summary: Git helpers for capistrano deployments
77
+ specification_version: 4
78
+ summary: Git helpers for Capistrano v3 deployments
48
79
  test_files: []
49
80
  has_rdoc:
data/README.rdoc DELETED
@@ -1,9 +0,0 @@
1
- = capistrano-gity
2
-
3
- Git deployment helpers for capistrano. Check the module for details :)
4
-
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Send a pull request.