dandelion 0.3.15 → 0.4.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +11 -0
- data/LICENSE +1 -1
- data/README.md +15 -26
- data/Rakefile +4 -8
- data/bin/dandelion +4 -3
- data/dandelion.gemspec +23 -20
- data/lib/dandelion.rb +26 -10
- data/lib/dandelion/adapter.rb +45 -0
- data/lib/dandelion/{backend → adapter}/ftp.rb +22 -17
- data/lib/dandelion/adapter/noop.rb +14 -0
- data/lib/dandelion/{backend → adapter}/s3.rb +14 -15
- data/lib/dandelion/{backend → adapter}/sftp.rb +29 -16
- data/lib/dandelion/change.rb +11 -0
- data/lib/dandelion/changeset.rb +49 -0
- data/lib/dandelion/cli.rb +127 -0
- data/lib/dandelion/command.rb +26 -92
- data/lib/dandelion/command/deploy.rb +54 -41
- data/lib/dandelion/command/status.rb +14 -13
- data/lib/dandelion/config.rb +36 -0
- data/lib/dandelion/deployer.rb +53 -0
- data/lib/dandelion/diff.rb +62 -0
- data/lib/dandelion/tree.rb +22 -0
- data/lib/dandelion/utils.rb +13 -0
- data/lib/dandelion/version.rb +2 -2
- data/lib/dandelion/workspace.rb +71 -0
- data/spec/dandelion/adapter_spec.rb +42 -0
- data/spec/dandelion/change_spec.rb +17 -0
- data/spec/dandelion/changeset_spec.rb +73 -0
- data/spec/dandelion/command/deploy_spec.rb +111 -0
- data/spec/dandelion/command/status_spec.rb +4 -0
- data/spec/dandelion/command_spec.rb +70 -0
- data/spec/dandelion/config_spec.rb +15 -0
- data/spec/dandelion/deployer_spec.rb +65 -0
- data/spec/dandelion/diff_spec.rb +54 -0
- data/spec/dandelion/tree_spec.rb +15 -0
- data/spec/dandelion/workspace_spec.rb +77 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/HEAD +0 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/config +1 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/description +0 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/hooks/applypatch-msg.sample +0 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/hooks/commit-msg.sample +0 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/hooks/post-update.sample +0 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/hooks/pre-applypatch.sample +0 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/hooks/pre-commit.sample +6 -2
- data/spec/fixtures/repo.git/hooks/pre-push.sample +53 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/hooks/pre-rebase.sample +0 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/hooks/prepare-commit-msg.sample +0 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/hooks/update.sample +1 -1
- data/{test/test_git.git → spec/fixtures/repo.git}/info/exclude +0 -0
- data/spec/fixtures/repo.git/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99 +0 -0
- data/spec/fixtures/repo.git/objects/34/e64fe350f3ea80c989cdac7a99c2adb8574fca +0 -0
- data/spec/fixtures/repo.git/objects/3d/9b743acb4a84dd99002d2c6f3fcf1a47e9f06b +0 -0
- data/spec/fixtures/repo.git/objects/4e/44973d41d33bf5342037f56497efe0a9604d25 +0 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6 +0 -0
- data/spec/fixtures/repo.git/objects/6c/a0f54491390579ce9438ec89c64c6b3499683a +0 -0
- data/spec/fixtures/repo.git/objects/8a/e33865a630c5d141c8a498f0c0166ff240b433 +0 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/objects/90/2dce0535b19f0c15ac8407fc4468256ad672d7 +0 -0
- data/spec/fixtures/repo.git/objects/c3/9af82404cc4267b1ba5f4b4437a511e0776abb +0 -0
- data/spec/fixtures/repo.git/objects/c8/85b3f693ed6e2926971ef75680f41b318072ae +0 -0
- data/spec/fixtures/repo.git/objects/d8/7cbcba0e2ede0752bdafc5938da35546803ba5 +0 -0
- data/spec/fixtures/repo.git/objects/e2/89ff1e2729839759dbd6fe99b6e35880910c7c +0 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
- data/{test/test_git.git → spec/fixtures/repo.git}/objects/ea/41dba10b54a794284e0be009a11f0ff3716a28 +0 -0
- data/spec/fixtures/repo.git/objects/ee/314a31b622b027c10981acaed7903a3607dbd4 +0 -0
- data/spec/fixtures/repo.git/objects/f6/66b137794d56880bab05e8fd256713a8fccf92 +0 -0
- data/spec/fixtures/repo.git/refs/heads/master +1 -0
- data/spec/spec_helper.rb +28 -0
- metadata +119 -127
- data/lib/dandelion/application.rb +0 -73
- data/lib/dandelion/backend.rb +0 -54
- data/lib/dandelion/deployment.rb +0 -173
- data/lib/dandelion/git.rb +0 -123
- data/test/fixtures/diff +0 -3
- data/test/fixtures/ls_tree +0 -5
- data/test/test_diff_deployment.rb +0 -122
- data/test/test_ftp.rb +0 -49
- data/test/test_git.git/hooks/post-commit.sample +0 -8
- data/test/test_git.git/hooks/post-receive.sample +0 -15
- data/test/test_git.git/objects/0c/a605e9f0f1d42ce8193ac36db11ec3cc9efc08 +0 -0
- data/test/test_git.git/objects/11/bada4e36fd065c8d1d3ca97b8dffa496c8e021 +0 -0
- data/test/test_git.git/objects/88/d4480861346093048e08ce8dcc577d8aa69379 +0 -1
- data/test/test_git.git/objects/a6/394b3e8a82b76b0dd5b6b317f489dfe22426a6 +0 -0
- data/test/test_git.git/objects/a6/5140d5ec9f47064f614ecf8e43776baa5c0c11 +0 -0
- data/test/test_git.git/objects/f5/5f3c44c89e5d215fbaaef9d33563117fe0b61b +0 -1
- data/test/test_git.git/objects/ff/1f1d4bd0c99e1c9cca047c46b2194accf89504 +0 -4
- data/test/test_git.git/refs/heads/master +0 -1
- data/test/test_git.rb +0 -50
- data/test/test_sftp.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0db6d6a95dd6dd735cef40b26ee73e674c17060a
|
4
|
+
data.tar.gz: a78f497fa3447eaa7e2049aa45ebbaec0238095b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef112d609e8e09b892039db536142f4d5ee270ec78aa90b29cfa3ecd15f2250a8e2919a081b757b97fce41b66b17579b08644ee433801710fb26fe9b2e0c0bc4
|
7
|
+
data.tar.gz: b16bfa52c5b20874e17454175b076ec3d3ae905e99b6853ae239a59e8810d507a5ef4c375a042c33ec45728e07507cf1801dda1d62473a7ba62ff899ae59524b
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,24 +1,19 @@
|
|
1
1
|
Dandelion
|
2
2
|
=========
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/dandelion.png)](http://badge.fury.io/rb/dandelion)
|
4
|
+
[![Build Status](https://travis-ci.org/scttnlsn/dandelion.png)](https://travis-ci.org/scttnlsn/dandelion)
|
4
5
|
[![Dependency Status](https://gemnasium.com/scttnlsn/dandelion.png)](https://gemnasium.com/scttnlsn/dandelion)
|
5
6
|
[![Code Climate](https://codeclimate.com/github/scttnlsn/dandelion.png)](https://codeclimate.com/github/scttnlsn/dandelion)
|
6
7
|
|
7
|
-
Incremental Git repository deployment
|
8
|
+
Incremental Git repository deployment.
|
8
9
|
|
9
10
|
Install
|
10
11
|
-------
|
11
12
|
|
12
|
-
Ensure that Ruby is installed, then run:
|
13
|
+
Ensure that Ruby >= 1.9 is installed, then run:
|
13
14
|
|
14
15
|
$ gem install dandelion
|
15
16
|
|
16
|
-
Alternatively, you can build the gem yourself:
|
17
|
-
|
18
|
-
$ git clone git://github.com/scttnlsn/dandelion.git
|
19
|
-
$ cd dandelion
|
20
|
-
$ rake install
|
21
|
-
|
22
17
|
Config
|
23
18
|
------
|
24
19
|
|
@@ -28,7 +23,7 @@ Git repository is searched for a file named `dandelion.yml`).
|
|
28
23
|
Example:
|
29
24
|
|
30
25
|
```yaml
|
31
|
-
|
26
|
+
adapter: sftp
|
32
27
|
host: example.com
|
33
28
|
username: user
|
34
29
|
password: pass
|
@@ -40,14 +35,12 @@ exclude:
|
|
40
35
|
- folder/
|
41
36
|
|
42
37
|
additional:
|
43
|
-
-
|
44
|
-
- public/css/screen.css
|
45
|
-
- public/js/main.js
|
38
|
+
- config/auth.yml
|
46
39
|
```
|
47
40
|
|
48
41
|
Required:
|
49
42
|
|
50
|
-
* `
|
43
|
+
* `adapter` (alias: `scheme`, the file transfer adapter)
|
51
44
|
|
52
45
|
Optional:
|
53
46
|
|
@@ -57,16 +50,16 @@ Optional:
|
|
57
50
|
* `additional` (additional list of files from your working directory that will be deployed)
|
58
51
|
* `revision_file` (remote file in which revision SHA is stored, defaults to .revision)
|
59
52
|
|
60
|
-
Each
|
53
|
+
Each adapter also has additional required and optional configuration parameters (see below).
|
61
54
|
|
62
|
-
|
63
|
-
|
55
|
+
Adapters
|
56
|
+
--------
|
64
57
|
|
65
|
-
There is support for multiple backend file transfer
|
66
|
-
must specify one of these
|
67
|
-
by the given
|
58
|
+
There is support for multiple backend file transfer adapters. The configuration
|
59
|
+
must specify one of these adapters and the set of additional parameters required
|
60
|
+
by the given adapter.
|
68
61
|
|
69
|
-
**SFTP**: `
|
62
|
+
**SFTP**: `adapter: sftp`
|
70
63
|
|
71
64
|
Required:
|
72
65
|
|
@@ -79,7 +72,7 @@ Optional:
|
|
79
72
|
* `port` (defaults to 22)
|
80
73
|
* `preserve_permissions` (defaults to true)
|
81
74
|
|
82
|
-
**FTP**: `
|
75
|
+
**FTP**: `adapter: ftp`
|
83
76
|
|
84
77
|
Required:
|
85
78
|
|
@@ -92,7 +85,7 @@ Optional:
|
|
92
85
|
* `port` (defaults to 21)
|
93
86
|
* `passive` (defaults to true)
|
94
87
|
|
95
|
-
**Amazon S3**: `
|
88
|
+
**Amazon S3**: `adapter: s3`
|
96
89
|
|
97
90
|
Required:
|
98
91
|
|
@@ -100,10 +93,6 @@ Required:
|
|
100
93
|
* `secret_access_key`
|
101
94
|
* `bucket_name`
|
102
95
|
|
103
|
-
Optional:
|
104
|
-
|
105
|
-
* `host` (defaults to s3.amazonaws.com)
|
106
|
-
|
107
96
|
Usage
|
108
97
|
-----
|
109
98
|
|
data/Rakefile
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
require '
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
3
|
|
4
|
-
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
|
-
|
7
|
-
test.libs << 'lib' << 'test'
|
8
|
-
test.pattern = 'test/**/test_*.rb'
|
9
|
-
test.verbose = true
|
10
|
-
end
|
6
|
+
task :default => :spec
|
data/bin/dandelion
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
lib = File.expand_path('../../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
|
5
|
-
require 'dandelion
|
6
|
+
require 'dandelion'
|
6
7
|
|
7
|
-
Dandelion::
|
8
|
+
Dandelion::CLI.new(ARGV.dup).execute!
|
data/dandelion.gemspec
CHANGED
@@ -1,26 +1,29 @@
|
|
1
|
-
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
2
3
|
|
3
4
|
require 'dandelion/version'
|
4
5
|
|
5
6
|
Gem::Specification.new do |s|
|
6
|
-
s.name
|
7
|
-
s.version
|
8
|
-
s.
|
9
|
-
s.
|
10
|
-
s.
|
11
|
-
s.homepage
|
12
|
-
s.
|
13
|
-
s.description = 'Incremental Git repository deployment'
|
14
|
-
s.license = 'MIT'
|
15
|
-
|
16
|
-
s.add_dependency 'grit', '>= 2.4.1'
|
17
|
-
|
18
|
-
s.add_development_dependency 'mocha', '>= 0.9.12'
|
19
|
-
s.add_development_dependency 'net-sftp', '>= 2.0.5'
|
20
|
-
s.add_development_dependency 'aws-s3', '>= 0.6.0'
|
7
|
+
s.name = 'dandelion'
|
8
|
+
s.version = Dandelion::VERSION
|
9
|
+
s.authors = ['Scott Nelson']
|
10
|
+
s.email = ['scott@scttnlsn.com']
|
11
|
+
s.summary = 'Incremental Git repository deployment'
|
12
|
+
s.homepage = 'https://github.com/scttnlsn/dandelion'
|
13
|
+
s.license = 'MIT'
|
21
14
|
|
22
|
-
s.files = `git ls-files`.split(
|
23
|
-
s.
|
24
|
-
s.
|
15
|
+
s.files = `git ls-files`.split($/)
|
16
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
25
18
|
s.require_paths = ['lib']
|
26
|
-
|
19
|
+
|
20
|
+
s.post_install_message = <<-MSG
|
21
|
+
! The 'dandelion' gem is installed but you may need to install additional
|
22
|
+
! gems depending on the adapters you intend to use.
|
23
|
+
!
|
24
|
+
! Running 'dandelion status' in your project directory will indicate which
|
25
|
+
! additional gems need to be installed.
|
26
|
+
MSG
|
27
|
+
|
28
|
+
s.add_dependency 'rugged', '~> 0.19.0'
|
29
|
+
end
|
data/lib/dandelion.rb
CHANGED
@@ -1,20 +1,36 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'rugged'
|
3
|
+
require 'dandelion/adapter'
|
4
|
+
require 'dandelion/cli'
|
5
|
+
require 'dandelion/change'
|
6
|
+
require 'dandelion/changeset'
|
7
|
+
require 'dandelion/command'
|
8
|
+
require 'dandelion/config'
|
9
|
+
require 'dandelion/diff'
|
10
|
+
require 'dandelion/deployer'
|
11
|
+
require 'dandelion/tree'
|
12
|
+
require 'dandelion/version'
|
13
|
+
require 'dandelion/workspace'
|
14
|
+
|
1
15
|
module Dandelion
|
2
16
|
class << self
|
3
17
|
def logger
|
4
|
-
return @
|
18
|
+
return @logger if @logger
|
19
|
+
|
5
20
|
$stdout.sync = true
|
6
|
-
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
21
|
+
|
22
|
+
@logger = Logger.new($stdout)
|
23
|
+
@logger.level = Logger::DEBUG
|
24
|
+
@logger.formatter = formatter
|
25
|
+
@logger
|
10
26
|
end
|
11
|
-
|
12
|
-
|
13
|
-
|
27
|
+
|
28
|
+
private
|
29
|
+
|
14
30
|
def formatter
|
15
|
-
proc do |severity, datetime, progname, msg|
|
31
|
+
proc do |severity, datetime, progname, msg|
|
16
32
|
"#{msg}\n"
|
17
33
|
end
|
18
34
|
end
|
19
35
|
end
|
20
|
-
end
|
36
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Dandelion
|
2
|
+
module Adapter
|
3
|
+
class InvalidAdapterError < StandardError; end
|
4
|
+
|
5
|
+
class MissingDependencyError < StandardError
|
6
|
+
attr_reader :gems
|
7
|
+
|
8
|
+
def initialize(gems)
|
9
|
+
@gems = gems
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Base
|
14
|
+
class << self
|
15
|
+
@@adapters = {}
|
16
|
+
|
17
|
+
def adapter(name)
|
18
|
+
@@adapters[name] = self
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_adapter(name, options = {})
|
22
|
+
klass = @@adapters[name]
|
23
|
+
raise InvalidAdapterError if klass.nil?
|
24
|
+
klass.new(options)
|
25
|
+
rescue LoadError
|
26
|
+
raise MissingDependencyError.new(klass.required_gems)
|
27
|
+
end
|
28
|
+
|
29
|
+
attr_reader :required_gems
|
30
|
+
|
31
|
+
def requires_gems(*gems)
|
32
|
+
@required_gems = gems
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def initialize(options)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
require 'dandelion/adapter/noop'
|
43
|
+
require 'dandelion/adapter/ftp'
|
44
|
+
require 'dandelion/adapter/sftp'
|
45
|
+
require 'dandelion/adapter/s3'
|
@@ -1,31 +1,27 @@
|
|
1
|
-
require 'dandelion/
|
1
|
+
require 'dandelion/utils'
|
2
2
|
|
3
3
|
module Dandelion
|
4
|
-
module
|
5
|
-
class FTP <
|
6
|
-
|
4
|
+
module Adapter
|
5
|
+
class FTP < Adapter::Base
|
6
|
+
include ::Dandelion::Utils
|
7
|
+
|
8
|
+
adapter 'ftp'
|
7
9
|
|
8
10
|
def initialize(config)
|
9
11
|
require 'net/ftp'
|
12
|
+
|
10
13
|
@config = config
|
11
|
-
@
|
12
|
-
@
|
13
|
-
|
14
|
-
@ftp
|
15
|
-
@ftp.chdir(@config['path']) if @config['path']
|
14
|
+
@config.defaults(port: Net::FTP::FTP_PORT)
|
15
|
+
@config[:passive] = to_b(@config[:passive])
|
16
|
+
|
17
|
+
@ftp = ftp_client
|
16
18
|
end
|
17
19
|
|
18
20
|
def read(file)
|
19
21
|
begin
|
20
|
-
|
21
|
-
# and 1.9 so we call FTP#retrbinary directly
|
22
|
-
content = ''
|
23
|
-
@ftp.retrbinary("RETR #{file}", 4096) do |data|
|
24
|
-
content += data
|
25
|
-
end
|
26
|
-
content
|
22
|
+
@ftp.getbinaryfile(file, nil)
|
27
23
|
rescue Net::FTPPermError => e
|
28
|
-
|
24
|
+
nil
|
29
25
|
end
|
30
26
|
end
|
31
27
|
|
@@ -54,6 +50,15 @@ module Dandelion
|
|
54
50
|
|
55
51
|
private
|
56
52
|
|
53
|
+
def ftp_client
|
54
|
+
ftp = Net::FTP.new
|
55
|
+
ftp.connect(@config['host'], @config['port'])
|
56
|
+
ftp.login(@config['username'], @config['password'])
|
57
|
+
ftp.passive = @config['passive']
|
58
|
+
ftp.chdir(@config['path']) if @config['path']
|
59
|
+
ftp
|
60
|
+
end
|
61
|
+
|
57
62
|
def cleanup(dir)
|
58
63
|
unless dir == File.dirname(dir)
|
59
64
|
if empty?(dir)
|
@@ -1,23 +1,22 @@
|
|
1
|
-
require 'dandelion/backend'
|
2
|
-
|
3
1
|
module Dandelion
|
4
|
-
module
|
5
|
-
class S3 <
|
6
|
-
|
7
|
-
|
2
|
+
module Adapter
|
3
|
+
class S3 < Adapter::Base
|
4
|
+
adapter 's3'
|
5
|
+
requires_gems 'aws-s3'
|
8
6
|
|
9
7
|
def initialize(config)
|
10
8
|
require 'aws/s3'
|
11
|
-
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
9
|
+
|
10
|
+
@access_key_id = config[:access_key_id]
|
11
|
+
@secret_access_key = config[:secret_access_key]
|
12
|
+
@bucket_name = config[:bucket_name]
|
13
|
+
@host = config[:host]
|
14
|
+
@path = config[:path]
|
16
15
|
end
|
17
16
|
|
18
17
|
def read(file)
|
19
18
|
s3connect!
|
20
|
-
|
19
|
+
return nil unless AWS::S3::S3Object.exists?(path(file), @bucket_name)
|
21
20
|
AWS::S3::S3Object.value(path(file), @bucket_name)
|
22
21
|
end
|
23
22
|
|
@@ -39,9 +38,9 @@ module Dandelion
|
|
39
38
|
|
40
39
|
def s3connect!
|
41
40
|
options = {
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
41
|
+
access_key_id: @access_key_id,
|
42
|
+
secret_access_key: @secret_access_key,
|
43
|
+
use_ssl: true
|
45
44
|
}
|
46
45
|
|
47
46
|
options[:server] = @host if @host
|