capistrano-deploytags 0.7.0 → 0.8.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.
Files changed (4) hide show
  1. checksums.yaml +15 -0
  2. data/README.md +74 -7
  3. data/lib/capistrano/deploy_tags.rb +18 -10
  4. metadata +17 -13
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTkwOGQ4YjJjOWZkMDg4ODEwMjM3NTJlZjEzZDhhYTI3YTFjYzczYw==
5
+ data.tar.gz: !binary |-
6
+ YzZkMDkxZWM1ZDgzZTJiZmE5NmYzNGM1MDkwYzA2OTAwMGQ0MGFhZQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MTA2OTY3NDU3MjI0MTZlMDJhMjY0M2M3MWMzNjhhN2Q2ZDA2MzJmMGY4N2Nj
10
+ ZGNjYzY3ODYzZmQ1MjAyZjMyN2QxOWUyNzVlY2ViODU2YWMyY2Q4NjM0MDE5
11
+ M2IwNjBhNmZjYzcxN2E0OWVhNzA0OGY5MDc3YmFjNTkyZTliOTg=
12
+ data.tar.gz: !binary |-
13
+ MTRiNGMxOTdhYzUzYzE1ZDBlZGFjMTEyNmE0NGM2NzdjZDlhYzMzYTAzNTFk
14
+ YzZlYjBiNTg0YTkyNjMzOTAyYWQyN2QxZDMxY2RmODQzMGVmZGRhMTU0YmY2
15
+ MDAzNWQ5NTkyMDMwZjRjYmNiNzg0Y2IyZmQwZTI4NjM1ZWNkOTE=
data/README.md CHANGED
@@ -39,19 +39,78 @@ In your Capistrano `config/deploy.rb` you should add:
39
39
  This will create two tasks, one that runs before deployment and one
40
40
  that runs after.
41
41
 
42
- NOTE: You will be creating and pushing tags from the version of the
43
- code in the current checkout. This plugin needs to be run from a
44
- clean checkout of your codebase. You should be deploying from a
45
- clean checkout anyway, so in most cases this is not a restriction
46
- on how you already do things. The plugin will check if your code
47
- is clean and complain if it is not.
42
+ *NOTE:* You will be creating and pushing tags from the version of the code in the
43
+ current checkout. This plugin needs to be run from a clean checkout of your
44
+ codebase. You should be deploying from a clean checkout anyway, so in most
45
+ cases this is not a restriction on how you already do things. The plugin will
46
+ check if your code is clean and complain if it is not.
47
+
48
+ *ALSO:* The plugin will do a pull to make sure you have the code on your local
49
+ system that will actually be deployed before checking the tree for changes.
50
+ Know this ahead of time as this may affect how you deal with your deployment
51
+ branches.
52
+
53
+ Setting the Remote
54
+ ------------------
55
+ By default, Capistrano Deploytags will use the first remote in the list returned
56
+ by `git remote`. If you prefer to use a different remote, then you may change the
57
+ `:git_remote` setting from your `deploy.rb`, the stage, or on the command line with
58
+ `-S git_remote=your-remote`.
59
+
60
+ Working on Your Deployment Scripts
61
+ ----------------------------------
62
+ Because you must have a clean tree to deploy, working on your deployment
63
+ scripts themselves can be a bit frustrating unless you know how to make it
64
+ work. The easiest way around this problem is to simply commit your changes
65
+ before you deploy. You do not have to push them. The plugin will then
66
+ happily carry on deploying without complaint.
67
+
68
+ Alternatively, you could disable the plugin temporarily with one of the
69
+ methods described below.
70
+
71
+ Disabling Tagging for a Stage
72
+ -----------------------------
73
+ Sometimes you do not want to enable deployment tagging for a particular
74
+ stage. In that event, you can simply disable tagging by setting `no_deploytags`
75
+ lik so:
76
+
77
+ ```ruby
78
+ set :no_deploytags, true
79
+ ```
80
+
81
+ You can also set this from the command line at any time with `-S no_deploytags=true`.
82
+
83
+ *NOTE:* this will disable the use of the plugin's functionality entirely for
84
+ that stage. The tasks will run, but will do nothing. This means that tasks that
85
+ are hooked to the Capistrano Deploytags tasks will also still run, but they may
86
+ find their expectations are not met with regards to the cleanliness of the git
87
+ tree.
88
+
89
+ Viewing Deployment History
90
+ --------------------------
91
+ It's trivial to view the deployment history for a repo. From a checkout
92
+ of the repo, type `git tag -l -n1`. The output looks something like:
93
+
94
+ ```
95
+ dev-2013.07.22-105130 baz deployed a4d522d9d to dev
96
+ dev-2013.07.22-113207 karl deployed 4c43f8464 to dev
97
+ dev-2013.07.22-114437 gavin deployed 776e15414 to dev
98
+ dev-2013.07.22-115103 karl deployed 619ff5724 to dev
99
+ dev-2013.07.22-144121 joshmyers deployed cf1ed1a02 to dev
100
+ ```
101
+
102
+ A little use of `grep` and you can easily get the history for a
103
+ particular (e.g. `git tag -l -n1 | grep dev`).
104
+
105
+ It should be noted that the names used when tags are created are the
106
+ local user name on the box where the deployment is done.
48
107
 
49
108
  Helpful Git Config
50
109
  ------------------
51
110
  You might find it useful to add this to your ~/.gitconfig in order
52
111
  to get a nice history view of the commits and tags.
53
112
 
54
- ```
113
+ ```ini
55
114
  [alias]
56
115
  lol = log --pretty=oneline --abbrev-commit --graph --decorate
57
116
  ```
@@ -59,6 +118,14 @@ to get a nice history view of the commits and tags.
59
118
  You can then view the list by typing `git lol` from the checked out
60
119
  code path.
61
120
 
121
+ Deploying a Previous Commit
122
+ ---------------------------
123
+ Because you have to actually be on the head of the branch you are
124
+ deploying in order for tagging to work properly, deploying a previous
125
+ commit doesn't work as you might expect. The simple solution is to
126
+ create a new branch from the previous commit you wish to deploy and
127
+ supplying `-S branch=<new branch>` as arguments to Capistrano.
128
+
62
129
  Credits
63
130
  -------
64
131
  This software was written by [Karl Matthias](https://github.com/relistan)
@@ -15,7 +15,7 @@ module Capistrano
15
15
 
16
16
  def validate_git_vars
17
17
  unless exists?(:branch) && exists?(:stage)
18
- logger.log Capistrano::Logger::IMPORTANT, "Capistrano Deploytags requires that :branch and :stage be defined."
18
+ logger.log Capistrano::Logger::IMPORTANT, 'Capistrano Deploytags requires that :branch and :stage be defined.'
19
19
  raise 'define :branch and :stage'
20
20
  end
21
21
  end
@@ -28,16 +28,22 @@ module Capistrano
28
28
  !`git remote`.strip.empty?
29
29
  end
30
30
 
31
+ def remote
32
+ exists?(:git_remote) ? git_remote : `git remote`.strip.split(/\n/).first
33
+ end
34
+
31
35
  def self.load_into(configuration)
32
36
  configuration.load do
33
- before "deploy", 'git:prepare_tree'
34
- before "deploy:migrations", 'git:prepare_tree'
35
- after "deploy", 'git:tagdeploy'
36
- after "deploy:migrations", 'git:tagdeploy'
37
+ before 'deploy', 'git:prepare_tree'
38
+ before 'deploy:migrations', 'git:prepare_tree'
39
+ after 'deploy', 'git:tagdeploy'
40
+ after 'deploy:migrations', 'git:tagdeploy'
37
41
 
38
42
  desc 'prepare git tree so we can tag on successful deployment'
39
43
  namespace :git do
40
44
  task :prepare_tree, :except => { :no_release => true } do
45
+ next if fetch(:no_deploytags, false)
46
+
41
47
  cdt.validate_git_vars
42
48
 
43
49
  logger.log Capistrano::Logger::IMPORTANT, "Preparing to deploy HEAD from branch '#{branch}' to '#{stage}'"
@@ -47,21 +53,23 @@ module Capistrano
47
53
  raise 'Dirty git tree'
48
54
  end
49
55
 
50
- cdt.safe_run "git", "checkout", branch
51
- cdt.safe_run "git", "pull", "origin", branch if cdt.has_remote?
56
+ cdt.safe_run 'git', 'checkout', branch
57
+ logger.log Capistrano::Logger::IMPORTANT, "Pulling from #{branch}"
58
+ cdt.safe_run 'git', 'pull', cdt.remote, branch if cdt.has_remote?
52
59
  end
53
60
 
54
61
  desc 'add git tags for each successful deployment'
55
62
  task :tagdeploy, :except => { :no_release => true } do
63
+ next if fetch(:no_deploytags, false)
64
+
56
65
  cdt.validate_git_vars
57
66
 
58
67
  current_sha = `git rev-parse #{branch} HEAD`.strip[0..8]
59
68
  logger.log Capistrano::Logger::INFO, "Tagging #{current_sha} for deployment"
60
69
 
61
70
  tag_user = (ENV['USER'] || ENV['USERNAME']).strip
62
- cdt.safe_run "git", "tag", "-a", cdt.git_tag_for(stage), "-m", "#{tag_user} deployed #{current_sha} to #{stage}"
63
-
64
- cdt.safe_run "git", "push", "--tags" if cdt.has_remote?
71
+ cdt.safe_run 'git', 'tag', '-a', cdt.git_tag_for(stage), '-m', "#{tag_user} deployed #{current_sha} to #{stage}"
72
+ cdt.safe_run 'git', 'push', '--tags' if cdt.has_remote?
65
73
  end
66
74
  end
67
75
 
metadata CHANGED
@@ -1,38 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-deploytags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
5
- prerelease:
4
+ version: 0.8.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Karl Matthias
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-10-02 00:00:00.000000000 Z
11
+ date: 2013-08-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: capistrano
16
- requirement: &2153587100 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *2153587100
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: capistrano-ext
27
- requirement: &2153586660 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ! '>='
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *2153586660
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  description: ! ' Capistrano Deploytags is a simple plugin to Capistrano that works
37
42
  with your deployment framework to track your code releases. All you have to do is
38
43
  require capistrano-deploytags and each deployment will add a new tag for that deployment,
@@ -52,26 +57,25 @@ files:
52
57
  - LICENSE
53
58
  homepage: http://github.com/mydrive/capistrano-deploytags
54
59
  licenses: []
60
+ metadata: {}
55
61
  post_install_message:
56
62
  rdoc_options: []
57
63
  require_paths:
58
64
  - lib
59
65
  required_ruby_version: !ruby/object:Gem::Requirement
60
- none: false
61
66
  requirements:
62
67
  - - ! '>='
63
68
  - !ruby/object:Gem::Version
64
69
  version: '0'
65
70
  required_rubygems_version: !ruby/object:Gem::Requirement
66
- none: false
67
71
  requirements:
68
72
  - - ! '>='
69
73
  - !ruby/object:Gem::Version
70
74
  version: '0'
71
75
  requirements: []
72
76
  rubyforge_project:
73
- rubygems_version: 1.8.11
77
+ rubygems_version: 2.0.6
74
78
  signing_key:
75
- specification_version: 3
79
+ specification_version: 4
76
80
  summary: Add dated, environment-specific tags to your git repo at each deployment.
77
81
  test_files: []