vlad-git 2.0.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/.autotest ADDED
@@ -0,0 +1,5 @@
1
+ require "autotest/restart"
2
+
3
+ Autotest.add_hook :initialize do |at|
4
+ at.testlib = "minitest/autorun"
5
+ end
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ === 2.0.0 / 2009-08-19
2
+
3
+ * Birthday!
data/Manifest.txt ADDED
@@ -0,0 +1,7 @@
1
+ .autotest
2
+ CHANGELOG.rdoc
3
+ Manifest.txt
4
+ README.rdoc
5
+ Rakefile
6
+ lib/vlad/git.rb
7
+ test/test_vlad_git.rb
data/README.rdoc ADDED
@@ -0,0 +1,40 @@
1
+ = Git for Vlad
2
+
3
+ * http://github.com/jbarnette/vlad-git
4
+ * http://rubyforge.org/projects/hitsquad
5
+
6
+ == Description
7
+
8
+ Vlad plugin for Git support. This was previously part of Vlad, but all
9
+ modules outside the core recipe have been extracted.
10
+
11
+ == Examples
12
+
13
+ Vlad.load :scm => :git
14
+
15
+ == Installation
16
+
17
+ $ gem install vlad-git
18
+
19
+ == License
20
+
21
+ Copyright 2009 Vlad contributors, John Barnette (jbarnette@rubyforge.org)
22
+
23
+ Permission is hereby granted, free of charge, to any person obtaining
24
+ a copy of this software and associated documentation files (the
25
+ 'Software'), to deal in the Software without restriction, including
26
+ without limitation the rights to use, copy, modify, merge, publish,
27
+ distribute, sublicense, and/or sell copies of the Software, and to
28
+ permit persons to whom the Software is furnished to do so, subject to
29
+ the following conditions:
30
+
31
+ The above copyright notice and this permission notice shall be
32
+ included in all copies or substantial portions of the Software.
33
+
34
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
35
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
37
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
38
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
39
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
40
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require "rubygems"
2
+ require "hoe"
3
+
4
+ Hoe.plugin :doofus, :git
5
+
6
+ Hoe.spec "vlad-git" do
7
+ developer "John Barnette", "jbarnette@rubyforge.org"
8
+
9
+ self.extra_rdoc_files = FileList["*.rdoc"]
10
+ self.history_file = "CHANGELOG.rdoc"
11
+ self.readme_file = "README.rdoc"
12
+ self.rubyforge_name = "hitsquad"
13
+ self.testlib = :minitest
14
+ end
data/lib/vlad/git.rb ADDED
@@ -0,0 +1,51 @@
1
+ class Vlad::Git
2
+
3
+ VERSION = "2.0.0"
4
+
5
+ set :source, Vlad::Git.new
6
+ set :git_cmd, "git"
7
+
8
+ ##
9
+ # Returns the command that will check out +revision+ from the
10
+ # repository into directory +destination+. +revision+ can be any
11
+ # SHA1 or equivalent (e.g. branch, tag, etc...)
12
+
13
+ def checkout(revision, destination)
14
+ destination = File.join(destination, 'repo')
15
+ revision = 'HEAD' if revision =~ /head/i
16
+
17
+ [ "rm -rf #{destination}",
18
+ "#{git_cmd} clone #{repository} #{destination}",
19
+ "cd #{destination}",
20
+ "#{git_cmd} checkout -f -b deployed-#{revision} #{revision}",
21
+ "cd -"
22
+ ].join(" && ")
23
+ end
24
+
25
+ ##
26
+ # Returns the command that will export +revision+ from the current directory
27
+ # into the directory +destination+.
28
+ # Expects to be run from +scm_path+ after Vlad::Git#checkout
29
+
30
+ def export(revision, destination)
31
+ revision = 'HEAD' if revision =~ /head/i
32
+ revision = "deployed-#{revision}"
33
+
34
+ [ "mkdir -p #{destination}",
35
+ "cd repo",
36
+ "#{git_cmd} archive --format=tar #{revision} | (cd #{destination} && tar xf -)",
37
+ "cd -",
38
+ "cd .."
39
+ ].join(" && ")
40
+ end
41
+
42
+ ##
43
+ # Returns a command that maps human-friendly revision identifier +revision+
44
+ # into a git SHA1.
45
+
46
+ def revision(revision)
47
+ revision = 'HEAD' if revision =~ /head/i
48
+
49
+ "`#{git_cmd} rev-parse #{revision}`"
50
+ end
51
+ end
@@ -0,0 +1,41 @@
1
+ require 'vlad_test_case'
2
+ require 'vlad'
3
+ require 'vlad/git'
4
+
5
+ class TestVladGit < VladTestCase
6
+ def setup
7
+ super
8
+ @scm = Vlad::Git.new
9
+ set :repository, "git@myhost:/home/john/project1"
10
+ end
11
+
12
+ # Checkout the way the default :update task invokes the method
13
+ def test_checkout
14
+ 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 checkout -f -b deployed-HEAD HEAD && cd -', cmd
16
+ end
17
+
18
+ # This is not how the :update task invokes the method
19
+ def test_checkout_revision
20
+ # Checkout to the current directory
21
+ cmd = @scm.checkout 'master', '.'
22
+ assert_equal 'rm -rf ./repo && git clone git@myhost:/home/john/project1 ./repo && cd ./repo && git checkout -f -b deployed-master master && cd -', cmd
23
+
24
+ # Checkout to a relative path
25
+ 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 checkout -f -b deployed-master master && cd -', cmd
27
+ end
28
+
29
+ def test_export
30
+ cmd = @scm.export 'master', 'the/release/path'
31
+ assert_equal 'mkdir -p the/release/path && cd repo && git archive --format=tar deployed-master | (cd the/release/path && tar xf -) && cd - && cd ..', cmd
32
+ end
33
+
34
+ def test_revision
35
+ ['head', 'HEAD'].each do |head|
36
+ cmd = @scm.revision(head)
37
+ expected = "`git rev-parse HEAD`"
38
+ assert_equal expected, cmd
39
+ end
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vlad-git
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - John Barnette
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-19 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.2
24
+ version:
25
+ description: |-
26
+ Vlad plugin for Git support. This was previously part of Vlad, but all
27
+ modules outside the core recipe have been extracted.
28
+ email:
29
+ - jbarnette@rubyforge.org
30
+ executables: []
31
+
32
+ extensions: []
33
+
34
+ extra_rdoc_files:
35
+ - Manifest.txt
36
+ - CHANGELOG.rdoc
37
+ - README.rdoc
38
+ files:
39
+ - .autotest
40
+ - CHANGELOG.rdoc
41
+ - Manifest.txt
42
+ - README.rdoc
43
+ - Rakefile
44
+ - lib/vlad/git.rb
45
+ - test/test_vlad_git.rb
46
+ has_rdoc: true
47
+ homepage: http://github.com/jbarnette/vlad-git
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options:
52
+ - --main
53
+ - README.rdoc
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ requirements: []
69
+
70
+ rubyforge_project: hitsquad
71
+ rubygems_version: 1.3.5
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Vlad plugin for Git support
75
+ test_files:
76
+ - test/test_vlad_git.rb