vlad-git 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,11 @@
1
+ === 2.2.0 / 2010-08-22
2
+
3
+ * New maintainer, Aaron Suggs!
4
+ * Expanded README
5
+ * Compatible with Vlad 2.1.
6
+ * Fixed git submodule initialization for older git versions (< 1.5.6).
7
+ * Add a fast checkout/update mode. [fisons]
8
+
1
9
  === 2.1.0 / 2009-10-14
2
10
 
3
11
  * Added git submodule support. [Balazs Nagy]
@@ -1,24 +1,53 @@
1
1
  = Git for Vlad
2
2
 
3
3
  * http://github.com/jbarnette/vlad-git
4
- * http://rubyforge.org/projects/hitsquad
4
+ * http://rubyhitsquad.com/Vlad_the_Deployer.html
5
5
 
6
6
  == Description
7
7
 
8
8
  Vlad plugin for Git support. This was previously part of Vlad, but all
9
9
  modules outside the core recipe have been extracted.
10
10
 
11
- == Examples
11
+ == Installation
12
12
 
13
- Vlad.load :scm => :git
13
+ $ gem install vlad-git
14
14
 
15
- == Installation
15
+ == Usage
16
+
17
+ (Adapted from Vlad's getting started guide:
18
+ http://hitsquad.rubyforge.org/vlad/doco/getting_started_txt.html)
19
+
20
+ In your Rakefile, load Vlad with the :scm => :git:
21
+
22
+ begin
23
+ require 'vlad'
24
+ Vlad.load :scm => :git
25
+ rescue
26
+ # do nothing
27
+ end
28
+
29
+ In config/deploy.rb, set the repository:
30
+
31
+ set :application, "project"
32
+ set :domain, "example.com"
33
+ set :deploy_to, "/path/to/install"
34
+ set :repository, 'git@example.com:project'
35
+
36
+ By default, vlad-git will deploy origin/master. To deploy an arbitrary
37
+ rev-spec, set the :revision in config/deploy.rb:
38
+
39
+ set :revision, "origin/my_branch" # Deploy a branch
40
+ set :revision, "v2.0" # Deploy a tag
41
+ set :revision, "a3539b3f3e9edba1" # Deploy a commit
42
+
43
+ == Contributors
16
44
 
17
- $ gem install vlad-git
45
+ * John Barnette http://github.com/jbarnette
46
+ * Aaron Suggs http://github.com/ktheory
18
47
 
19
48
  == License
20
49
 
21
- Copyright 2009 Vlad contributors, John Barnette (jbarnette@rubyforge.org)
50
+ Copyright 2009 Vlad contributors, John Barnette (code@jbarnette.com)
22
51
 
23
52
  Permission is hereby granted, free of charge, to any person obtaining
24
53
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,14 +1,16 @@
1
1
  require "rubygems"
2
2
  require "hoe"
3
3
 
4
+ Hoe.plugins.delete :rubyforge
4
5
  Hoe.plugin :doofus, :git
5
6
 
6
7
  Hoe.spec "vlad-git" do
7
- developer "John Barnette", "jbarnette@rubyforge.org"
8
+ developer "John Barnette", "code@jbarnette.com"
9
+ developer "Aaron Suggs", "aaron@ktheory.com"
8
10
 
9
11
  self.extra_rdoc_files = FileList["*.rdoc"]
10
12
  self.history_file = "CHANGELOG.rdoc"
11
13
  self.readme_file = "README.rdoc"
12
- self.rubyforge_name = "hitsquad"
13
14
  self.testlib = :minitest
15
+ self.extra_deps << ["vlad", ">= 2.1.0"]
14
16
  end
@@ -1,12 +1,11 @@
1
1
  class Vlad::Git
2
2
 
3
3
  # Duh.
4
- VERSION = "2.1.0"
4
+ VERSION = "2.2.0"
5
5
 
6
6
  set :source, Vlad::Git.new
7
7
  set :git_cmd, "git"
8
8
 
9
- ##
10
9
  # Returns the command that will check out +revision+ from the
11
10
  # repository into directory +destination+. +revision+ can be any
12
11
  # SHA1 or equivalent (e.g. branch, tag, etc...)
@@ -14,20 +13,34 @@ class Vlad::Git
14
13
  def checkout(revision, destination)
15
14
  destination = File.join(destination, 'repo')
16
15
  revision = 'HEAD' if revision =~ /head/i
16
+ new_revision = ('HEAD' == revision) ? "origin" : revision
17
17
 
18
- [ "rm -rf #{destination}",
19
- "#{git_cmd} clone #{repository} #{destination}",
20
- "cd #{destination}",
21
- "#{git_cmd} submodule update --init",
22
- "#{git_cmd} checkout -f -b deployed-#{revision} #{revision}",
23
- "cd -"
24
- ].join(" && ")
18
+ if fast_checkout_applicable?(revision, destination)
19
+ [ "cd #{destination}",
20
+ "#{git_cmd} checkout -q origin",
21
+ "#{git_cmd} fetch",
22
+ "#{git_cmd} reset --hard #{new_revision}",
23
+ "#{git_cmd} submodule init",
24
+ "#{git_cmd} submodule update",
25
+ "#{git_cmd} branch -f deployed-#{revision} #{revision}",
26
+ "#{git_cmd} checkout deployed-#{revision}",
27
+ "cd -"
28
+ ].join(" && ")
29
+ else
30
+ [ "rm -rf #{destination}",
31
+ "#{git_cmd} clone #{repository} #{destination}",
32
+ "cd #{destination}",
33
+ "#{git_cmd} submodule init",
34
+ "#{git_cmd} submodule update",
35
+ "#{git_cmd} checkout -f -b deployed-#{revision} #{revision}",
36
+ "cd -"
37
+ ].join(" && ")
38
+ end
25
39
  end
26
40
 
27
- ##
28
- # Returns the command that will export +revision+ from the current directory
29
- # into the directory +destination+.
30
- # Expects to be run from +scm_path+ after Vlad::Git#checkout
41
+ # Returns the command that will export +revision+ from the current
42
+ # directory into the directory +destination+. Expects to be run
43
+ # from +scm_path+ after Vlad::Git#checkout.
31
44
 
32
45
  def export(revision, destination)
33
46
  revision = 'HEAD' if revision =~ /head/i
@@ -42,13 +55,30 @@ class Vlad::Git
42
55
  ].join(" && ")
43
56
  end
44
57
 
45
- ##
46
- # Returns a command that maps human-friendly revision identifier +revision+
47
- # into a git SHA1.
58
+ # Returns a command that maps human-friendly revision identifier
59
+ # +revision+ into a git SHA1.
48
60
 
49
61
  def revision(revision)
50
62
  revision = 'HEAD' if revision =~ /head/i
51
63
 
52
64
  "`#{git_cmd} rev-parse #{revision}`"
53
65
  end
66
+
67
+ private
68
+
69
+ # Checks if fast-checkout is applicable
70
+ def fast_checkout_applicable?(revision, destination)
71
+ revision = 'HEAD' if revision =~ /head/i
72
+
73
+ begin
74
+ cmd = [ "if cd #{destination}",
75
+ "#{git_cmd} rev-parse #{revision}",
76
+ "#{git_cmd} remote -v | grep -q #{repository}",
77
+ "cd -; then exit 0; else exit 1; fi &>/dev/null" ].join(" && ")
78
+ run cmd
79
+ return true
80
+ rescue Rake::CommandFailedError
81
+ return false
82
+ end
83
+ end
54
84
  end
@@ -1,33 +1,55 @@
1
- require 'vlad_test_case'
1
+ require 'minitest/autorun'
2
2
  require 'vlad'
3
3
  require 'vlad/git'
4
+ require 'mocha'
4
5
 
5
- class TestVladGit < VladTestCase
6
+ class TestVladGit < MiniTest::Unit::TestCase
6
7
  def setup
7
8
  super
8
9
  @scm = Vlad::Git.new
10
+ @scm.stubs(:fast_checkout_applicable?).returns(false)
11
+
12
+ @scm_fast = Vlad::Git.new
13
+ @scm_fast.stubs(:fast_checkout_applicable?).returns(true)
14
+
9
15
  set :repository, "git@myhost:/home/john/project1"
10
16
  end
11
17
 
12
18
  # Checkout the way the default :update task invokes the method
13
19
  def test_checkout
14
20
  cmd = @scm.checkout 'head', '/the/scm/path'
15
- assert_equal 'rm -rf /the/scm/path/repo && git clone git@myhost:/home/john/project1 /the/scm/path/repo && cd /the/scm/path/repo && git submodule update --init && git checkout -f -b deployed-HEAD HEAD && cd -', cmd
21
+ assert_equal 'rm -rf /the/scm/path/repo && git clone git@myhost:/home/john/project1 /the/scm/path/repo && cd /the/scm/path/repo && git submodule init && git submodule update && git checkout -f -b deployed-HEAD HEAD && cd -', cmd
22
+ end
23
+
24
+ # (fast-mode) Checkout the way the default :update task invokes the method
25
+ def test_checkout_fast
26
+ cmd = @scm_fast.checkout 'head', '/the/scm/path'
27
+ assert_equal 'cd /the/scm/path/repo && git checkout -q origin && git fetch && git reset --hard origin && git submodule init && git submodule update && git branch -f deployed-HEAD HEAD && git checkout deployed-HEAD && cd -', cmd
16
28
  end
17
29
 
18
30
  # This is not how the :update task invokes the method
19
31
  def test_checkout_revision
20
32
  # Checkout to the current directory
21
33
  cmd = @scm.checkout 'master', '.'
22
- assert_equal "rm -rf ./repo && git clone git@myhost:/home/john/project1 ./repo && cd ./repo && git submodule update --init && git checkout -f -b deployed-master master && cd -", cmd
34
+ assert_equal 'rm -rf ./repo && git clone git@myhost:/home/john/project1 ./repo && cd ./repo && git submodule init && git submodule update && git checkout -f -b deployed-master master && cd -', cmd
23
35
 
24
36
  # Checkout to a relative path
25
37
  cmd = @scm.checkout 'master', 'some/relative/path'
26
- assert_equal 'rm -rf some/relative/path/repo && git clone git@myhost:/home/john/project1 some/relative/path/repo && cd some/relative/path/repo && git submodule update --init && git checkout -f -b deployed-master master && cd -', cmd
38
+ assert_equal 'rm -rf some/relative/path/repo && git clone git@myhost:/home/john/project1 some/relative/path/repo && cd some/relative/path/repo && git submodule init && git submodule update && git checkout -f -b deployed-master master && cd -', cmd
39
+ end
40
+
41
+ # (fast-mode) This is not how the :update task invokes the method
42
+ def test_checkout_revision_fast
43
+ # Checkout to the current directory
44
+ cmd = @scm_fast.checkout 'master', '.'
45
+ assert_equal 'cd ./repo && git checkout -q origin && git fetch && git reset --hard master && git submodule init && git submodule update && git branch -f deployed-master master && git checkout deployed-master && cd -', cmd
27
46
 
47
+ cmd = @scm_fast.checkout 'master', 'some/relative/path'
48
+ assert_equal 'cd some/relative/path/repo && git checkout -q origin && git fetch && git reset --hard master && git submodule init && git submodule update && git branch -f deployed-master master && git checkout deployed-master && cd -', cmd
28
49
  end
29
50
 
30
51
  def test_export
52
+ # default mode
31
53
  cmd = @scm.export 'master', 'the/release/path'
32
54
  assert_equal "mkdir -p the/release/path && cd repo && git archive --format=tar deployed-master | (cd the/release/path && tar xf -) && git submodule foreach 'git archive --format=tar \$sha1 | (cd the/release/path/\$path && tar xf -)' && cd - && cd ..", cmd
33
55
  end
@@ -40,3 +62,4 @@ class TestVladGit < VladTestCase
40
62
  end
41
63
  end
42
64
  end
65
+
metadata CHANGED
@@ -1,32 +1,62 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vlad-git
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ hash: 7
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 2
9
+ - 0
10
+ version: 2.2.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - John Barnette
14
+ - Aaron Suggs
8
15
  autorequire:
9
16
  bindir: bin
10
17
  cert_chain: []
11
18
 
12
- date: 2009-10-14 00:00:00 -07:00
19
+ date: 2010-08-22 00:00:00 -07:00
13
20
  default_executable:
14
21
  dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: vlad
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 11
31
+ segments:
32
+ - 2
33
+ - 1
34
+ - 0
35
+ version: 2.1.0
36
+ type: :runtime
37
+ version_requirements: *id001
15
38
  - !ruby/object:Gem::Dependency
16
39
  name: hoe
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
20
43
  requirements:
21
44
  - - ">="
22
45
  - !ruby/object:Gem::Version
23
- version: 2.3.3
24
- version:
46
+ hash: 21
47
+ segments:
48
+ - 2
49
+ - 6
50
+ - 1
51
+ version: 2.6.1
52
+ type: :development
53
+ version_requirements: *id002
25
54
  description: |-
26
55
  Vlad plugin for Git support. This was previously part of Vlad, but all
27
56
  modules outside the core recipe have been extracted.
28
57
  email:
29
- - jbarnette@rubyforge.org
58
+ - code@jbarnette.com
59
+ - aaron@ktheory.com
30
60
  executables: []
31
61
 
32
62
  extensions: []
@@ -54,21 +84,27 @@ rdoc_options:
54
84
  require_paths:
55
85
  - lib
56
86
  required_ruby_version: !ruby/object:Gem::Requirement
87
+ none: false
57
88
  requirements:
58
89
  - - ">="
59
90
  - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
60
94
  version: "0"
61
- version:
62
95
  required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
63
97
  requirements:
64
98
  - - ">="
65
99
  - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
66
103
  version: "0"
67
- version:
68
104
  requirements: []
69
105
 
70
- rubyforge_project: hitsquad
71
- rubygems_version: 1.3.5
106
+ rubyforge_project: vlad-git
107
+ rubygems_version: 1.3.7
72
108
  signing_key:
73
109
  specification_version: 3
74
110
  summary: Vlad plugin for Git support