cap_git_tools 0.8.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTRmMGUzNWE5ZWFhYzZiMTQ0MGJkMGUzYjk2Njg4MmQyYmQ5ZGIxOA==
5
+ data.tar.gz: !binary |-
6
+ MmFkMmNhMmRmZGMyNGZmM2JlOWMzYTM3MDYwNTQ1ZGJhMGNhYzk4Yg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MGRkZDhlYTFiOThkMDk2M2ZjNTA4NTE0ZjMzNGVkNmJkMjIzYzFhYWFmNmQ5
10
+ NTdkZjA4MGUyYzJkYTkwYzY0MWUzOWE0NTAxODJmZDQ5ZjI2ODhmYzNmNTlm
11
+ N2Y5ODAyNmU3Mjg5NmU3NmVkZWMyOTlmNGFkNzNhNWYxY2Y4NTI=
12
+ data.tar.gz: !binary |-
13
+ NGU4M2EyNzBhZWZkOTI2YTk0YTk4MmE1Mzg4ZTBkMzZiMDVjZDk2MmQxOTFj
14
+ NGYxOTkyZGUzYTFkN2QwZjZhYjk4YTYxYmJmYTg1YzBlOTU0MjU1NGEyNmUx
15
+ MTA2ZmIwZjA1MThhNTk1M2I4MjY1MzM2NTE1ZDFiZjUyYzVhY2Q=
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # cap_git_tools
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/cap_git_tools.png)](http://badge.fury.io/rb/cap_git_tools)
4
+
3
5
  Re-usable, composable [Capistrano](https://github.com/capistrano/capistrano) tasks for git tagging and other work with the
4
6
  git repository you use for your Cap deploys.
5
7
 
@@ -18,7 +20,7 @@ to be using it.
18
20
  (_Inspired by Alan Pinstein and Josh Nichols' neat
19
21
  [gitflow](https://github.com/apinstein/git-deployment), but refactored for more
20
22
  flexiblity with less hardcoded workflow. Some functionality changed in the
21
- process.)_
23
+ process.)
22
24
 
23
25
  ## Installation
24
26
 
@@ -37,7 +39,9 @@ This makes cap_git_tool's tasks available to you, but doesn't automatically wire
37
39
  them up to be used by your `cap deploy`. See below.
38
40
 
39
41
  You probably want to make sure you have an `ssh-agent` set up, or you'll have to
40
- enter your private key password to access git several times. You will need to be
42
+ enter your private key password to access git several times.
43
+
44
+ **Note**: You will need to be
41
45
  running your cap recipes from a directory with a git checkout (usual behavior
42
46
  for cap usage, but not actually required otherwise by cap).
43
47
 
@@ -79,7 +83,7 @@ you have set cap's `:branch`, it'll tag and deploy the HEAD of that branch
79
83
  even if that's not your current checkout.
80
84
 
81
85
  You can customize the prefix and other aspects of tagging, both in your recipe
82
- and with command line over-rides, see `cap -E git:tag` for more info.
86
+ and with command line over-rides, see `cap -e git:tag` for more info.
83
87
 
84
88
  ## Multistage workflow
85
89
 
@@ -89,7 +93,7 @@ In one commonly desired multistage workflow (similar to what
89
93
  [gitflow](https://github.com/apinstein/git-deployment) enforces):
90
94
 
91
95
  * Under staging, you want automatic tagging with staging-yyyy-mm-dd-hhmm, just
92
- as above under 'Automatically tag on deploy'. Add to your `config/staging.rb`:
96
+ as above under 'Automatically tag on deploy'. Add to your `config/deploy/staging.rb`:
93
97
 
94
98
  before "deploy:update_code", "git:guard_committed", "git:guard_upstream", "git:tag"
95
99
 
@@ -97,7 +101,7 @@ In one commonly desired multistage workflow (similar to what
97
101
  it by deploying that tag to production, re-tagging with a "production-" tag.
98
102
  Maybe you also want to print out the commit log between the last production
99
103
  tag and what you're about to deploy, and require interactive confirmation.
100
- Add to your `config/deploy.rb`:
104
+ Add to your `config/deploy/production.rb`:
101
105
 
102
106
  before "deploy:update_code", "git:commit_log", "git:retag"
103
107
  set :confirm_tag, true
@@ -167,4 +171,4 @@ point.
167
171
  ## Let me know
168
172
 
169
173
  Feedback, pull requests, complaints, welcome. Not sure if anyone's gonna use
170
- this.
174
+ this.
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = CapGitTools::VERSION
8
8
  s.authors = ["Jonathan Rochkind"]
9
9
  s.email = ["jonathan@dnil.net"]
10
- s.homepage = ""
10
+ s.homepage = "http://github.com/jrochkind/cap_git_tools"
11
11
  s.summary = %q{re-usable, composable Capistrano tasks for git tagging and other work with a git repo}
12
12
 
13
13
  s.rubyforge_project = "cap_git_tools"
@@ -37,38 +37,47 @@ module CapGitTools::TaskHelpers
37
37
  # will occasionally return a raw git url when it's not configured in
38
38
  # remotes for some reason.
39
39
  #
40
- # This used to be hard-coded to 'origin'. Then it was configurable.
41
- # Then I realized it _has_ to be whatever is set in cap :repository.
42
- # We'll look up the remote alias for that, if available, and cache
43
- # the lookup. Usually it'll be 'origin', yeah.
40
+ # When using deploy_via copy, will find the remote if the repository only
41
+ # has one configured. If more than one remote is configured an error will
42
+ # be raised unless the `upstream_remote_name` variable is set specifying the
43
+ # correct remote.
44
+ #
45
+ # Remote determination can be overridden manually for any deployment method
46
+ # by setting the remote to use in the `upstream_remote_name` variable.
44
47
  def upstream_remote
45
48
  @__upstream_remote = begin
46
- git_url = fetch(:repository)
47
-
48
- remote_info =
49
- `git remote -v`.
50
- split("\n").
51
- collect {|line| line.split(/[\t ]/) }.
52
- find {|list| list[1] == git_url }
53
-
54
- remote_info ? remote_info[0] : git_url
49
+ if exists?('upstream_remote_name')
50
+ fetch(:upstream_remote_name)
51
+ elsif fetch(:deploy_via) == :copy
52
+ upstream_remote_for_copy
53
+ else
54
+ git_url = fetch(:repository)
55
+ upstream_remote_by_url git_url
56
+ end
55
57
  end
56
58
  end
57
-
59
+
58
60
 
59
61
  # what branch we're going to tag and deploy -- if cap 'branch' is set,
60
62
  # use that one, otherwise use current branch in checkout
61
63
  def working_branch
62
64
  @__git_working_branch ||= begin
63
65
  if exists?("branch")
66
+ p fetch(:branch)
64
67
  fetch(:branch)
65
68
  else
66
- b = `git symbolic-ref -q HEAD`.sub(%r{^refs/heads/}, '').chomp
67
- b.empty? ? "HEAD" : b
69
+ current_branch
68
70
  end
69
71
  end
70
72
 
71
73
  end
74
+
75
+ # The branch that is currently checkout out in the local repository
76
+ def current_branch
77
+ b = `git symbolic-ref -q HEAD`.sub(%r{^refs/heads/}, '').chomp
78
+ b.empty? ? "HEAD" : b
79
+ return b
80
+ end
72
81
 
73
82
  # current SHA fingerprint of local branch mentioned in :branch
74
83
  def local_sha
@@ -189,6 +198,28 @@ module CapGitTools::TaskHelpers
189
198
  end
190
199
  end
191
200
  end
201
+
202
+ def upstream_remote_by_url(git_url)
203
+ remote_info =
204
+ `git remote -v`.
205
+ split("\n").
206
+ collect {|line| line.split(/[\t ]/) }.
207
+ find {|list| list[1] == git_url }
208
+
209
+ remote_info ? remote_info[0] : git_url
210
+ end
192
211
 
193
-
212
+ def upstream_remote_for_copy
213
+ remotes = `git remote`.split("\n")
214
+ remotes.size == 1 ? remotes[0] : abort(%Q{failed: upstream_remote: multiple possible upstream remotes
215
+
216
+ You are deploying via copy, and have multiple possible upstream remotes.
217
+
218
+ Please specify the correct remote to use by setting the
219
+ :upstream_remote_name variable.
220
+
221
+ Available remotes:
222
+ #{remotes.join("\n ")}
223
+ })
224
+ end
194
225
  end
@@ -196,8 +196,8 @@ Capistrano::Configuration.instance.load do
196
196
  * Normally the most recent tag beginning "staging-"
197
197
  * Or set cap :tag_prefix in config file or command line
198
198
  to use a different prefix.
199
- * Or set :tag_from in config file or on command line
200
- to specify a specific tag. `cap deploy -s tag_from=staging_something`
199
+ * Or set :from_tag in config file or on command line
200
+ to specify a specific tag. `cap deploy -s from_tag=staging_something`
201
201
 
202
202
  What will the newly created tag look like? Same rules as for
203
203
  git:tag.
@@ -1,3 +1,3 @@
1
1
  module CapGitTools
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.1"
3
3
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cap_git_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
5
- prerelease:
4
+ version: 0.9.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jonathan Rochkind
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-06-07 00:00:00.000000000 Z
11
+ date: 2013-03-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: capistrano
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -43,29 +40,29 @@ files:
43
40
  - lib/cap_git_tools/task_helpers.rb
44
41
  - lib/cap_git_tools/tasks.rb
45
42
  - lib/cap_git_tools/version.rb
46
- homepage: ''
43
+ homepage: http://github.com/jrochkind/cap_git_tools
47
44
  licenses: []
45
+ metadata: {}
48
46
  post_install_message:
49
47
  rdoc_options: []
50
48
  require_paths:
51
49
  - lib
52
50
  required_ruby_version: !ruby/object:Gem::Requirement
53
- none: false
54
51
  requirements:
55
52
  - - ! '>='
56
53
  - !ruby/object:Gem::Version
57
54
  version: '0'
58
55
  required_rubygems_version: !ruby/object:Gem::Requirement
59
- none: false
60
56
  requirements:
61
57
  - - ! '>='
62
58
  - !ruby/object:Gem::Version
63
59
  version: '0'
64
60
  requirements: []
65
61
  rubyforge_project: cap_git_tools
66
- rubygems_version: 1.8.24
62
+ rubygems_version: 2.0.3
67
63
  signing_key:
68
- specification_version: 3
64
+ specification_version: 4
69
65
  summary: re-usable, composable Capistrano tasks for git tagging and other work with
70
66
  a git repo
71
67
  test_files: []
68
+ has_rdoc: