capistrano-scm-localgitcopy 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +61 -0
- data/Rakefile +0 -0
- data/capistrano-scm-localgitcopy.gemspec +21 -0
- data/lib/capistrano-scm-localgitcopy.rb +1 -0
- data/lib/capistrano/scm/localgitcopy.rb +28 -0
- data/lib/capistrano/scm/tasks/localgitcopy.rake +60 -0
- metadata +69 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 880f05e66fda0b335b5ca54abf89849e928b3a07
|
4
|
+
data.tar.gz: 5498d768ac01d408d321bdbab8b79ac0cd010e80
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c23c3db9fd41f3c97e5ea7e1816d037715b4e75cc217bee68ddb884fe74450ec8df4cdbabe8c9a9400e3df4531333f7525eace07dd22de3997adba1785c87837
|
7
|
+
data.tar.gz: 8f0374c1946adac164b48ef6b05ac56f9d649226855f0f1540797da590d00bf702d66a98abe8a526440107ca712f1d633255062c4045d829074e1ac51edf2a33
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 creative-workflow
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# capistrano-scm-localgitcopy
|
2
|
+
|
3
|
+
A copy strategy for Capistrano 3, which uses `git ls-files` local, tars the files, uploads and extracts.
|
4
|
+
|
5
|
+
It depends on the local git revision.
|
6
|
+
|
7
|
+
It is helpfull if you have a shred web hoster like netcup with a very limited set of commands.
|
8
|
+
|
9
|
+
## Requirements
|
10
|
+
Machine running Capistrano:
|
11
|
+
|
12
|
+
- Capistrano 3
|
13
|
+
- tar
|
14
|
+
- git
|
15
|
+
|
16
|
+
Servers:
|
17
|
+
|
18
|
+
- tar
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
First make sure you install the capistrano-scm-localgitcopy by adding it to your `Gemfile`:
|
22
|
+
|
23
|
+
gem "capistrano-scm-localgitcopy"
|
24
|
+
|
25
|
+
Add to Capfile:
|
26
|
+
|
27
|
+
require 'capistrano/scm/localgitcopy'
|
28
|
+
install_plugin Capistrano::SCM::Localgitcopy
|
29
|
+
|
30
|
+
## Configuration (defaults)
|
31
|
+
```
|
32
|
+
set :archive_name, 'deploy-archive.tar.gz' # local archive name
|
33
|
+
set :include_dir, './' # you can use a subfolder for deployment
|
34
|
+
set :tar_roles, :all # roles to run on tar
|
35
|
+
set :tar_verbose, true # enable verbose mode for tar
|
36
|
+
set :exclude_dir, nil # exclude directories
|
37
|
+
set :temp_file, '/tmp/deploy-archive.tar.gz' # temp file on server
|
38
|
+
```
|
39
|
+
|
40
|
+
## Pitfall: git and utf 8 chars
|
41
|
+
If you have problems with utf8 chars in file names that wont included in the deploy tar, do the following:
|
42
|
+
|
43
|
+
```
|
44
|
+
$ git config --global core.precomposeunicode true
|
45
|
+
$ git config core.precomposeunicode.true
|
46
|
+
|
47
|
+
$ git ls-files | grep "\""
|
48
|
+
$ git rm --cached "`printf "<File>"`" #this for each file
|
49
|
+
$ git commit -m "clean up bad encoding of file names"
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
### License
|
54
|
+
The MIT License (MIT)
|
55
|
+
|
56
|
+
### Changelog
|
57
|
+
|
58
|
+
0.1.0
|
59
|
+
-----
|
60
|
+
|
61
|
+
- Initial release
|
data/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "capistrano-scm-localgitcopy"
|
6
|
+
s.version = "0.1.0"
|
7
|
+
s.licenses = ["MIT"]
|
8
|
+
s.authors = ["Tom Hanoldt"]
|
9
|
+
s.email = ["tom@creative-workflow.berlin"]
|
10
|
+
s.homepage = "https://github.com/creative-workflow/capistrano-scm-localgitcopy"
|
11
|
+
s.summary = %q{A copy strategy for Capistrano 3, which uses `git ls-files` local, tars the files, uploads and extracts.}
|
12
|
+
s.description = %q{A copy strategy for Capistrano 3, which uses `git ls-files` local, tars the files, uploads and extracts.}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
# specify any dependencies here; for example:
|
20
|
+
s.add_dependency "capistrano", "~> 3.0"
|
21
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "capistrano/scm/plugin"
|
2
|
+
|
3
|
+
class Capistrano::SCM::Localgitcopy < ::Capistrano::SCM::Plugin
|
4
|
+
def set_defaults
|
5
|
+
set_if_empty :archive_name, 'deploy-archive.tar.gz'
|
6
|
+
set_if_empty :include_dir, './'
|
7
|
+
set_if_empty :tar_roles, :all
|
8
|
+
set_if_empty :tar_verbose, true
|
9
|
+
set_if_empty :exclude_dir, nil
|
10
|
+
set_if_empty :temp_file, '/tmp/deploy-archive.tar.gz'
|
11
|
+
end
|
12
|
+
|
13
|
+
def define_tasks
|
14
|
+
eval_rakefile File.expand_path("tasks/localgitcopy.rake", File.dirname(__FILE__))
|
15
|
+
end
|
16
|
+
|
17
|
+
def register_hooks
|
18
|
+
before 'deploy:started', 'localgitcopy:clean'
|
19
|
+
after 'deploy:new_release_path', 'localgitcopy:create_archive'
|
20
|
+
after 'localgitcopy:create_archive', 'localgitcopy:create_release'
|
21
|
+
before 'deploy:set_current_revision', 'localgitcopy:set_current_revision'
|
22
|
+
after 'deploy:finished', 'localgitcopy:clean'
|
23
|
+
end
|
24
|
+
|
25
|
+
def fetch_revision
|
26
|
+
`git rev-list --max-count=1 $(git rev-parse --abbrev-ref HEAD)`
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
copy_plugin = self
|
2
|
+
|
3
|
+
namespace :localgitcopy do
|
4
|
+
task :create_release do
|
5
|
+
on release_roles :all do
|
6
|
+
set(:branch, copy_plugin.fetch_revision)
|
7
|
+
execute :mkdir, "-p", release_path
|
8
|
+
|
9
|
+
repo_path = "#{fetch(:deploy_to)}/repo"
|
10
|
+
execute :mkdir, "-p", repo_path
|
11
|
+
|
12
|
+
# Create a temporary file on the server
|
13
|
+
tmp_file = fetch(:temp_file)
|
14
|
+
archive_name = fetch(:archive_name)
|
15
|
+
|
16
|
+
execute :rm, "-f", tmp_file
|
17
|
+
execute :touch, tmp_file
|
18
|
+
|
19
|
+
# Upload the archive, extract it and finally remove the tmp_file
|
20
|
+
upload!(archive_name, tmp_file)
|
21
|
+
execute :tar, "-xzf", tmp_file, "-C", "#{release_path}"
|
22
|
+
execute :rm, tmp_file
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "Determine the revision that will be deployed"
|
27
|
+
task :set_current_revision do
|
28
|
+
on release_roles :all do
|
29
|
+
within repo_path do
|
30
|
+
set :current_revision, copy_plugin.fetch_revision
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
task :create_archive do
|
36
|
+
on release_roles :all do
|
37
|
+
archive_name = fetch(:archive_name)
|
38
|
+
tar_verbose = fetch(:tar_verbose, true) ? "v" : ""
|
39
|
+
tar_roles = fetch(:tar_roles, :all)
|
40
|
+
include_dir = fetch(:include_dir)
|
41
|
+
exclude_dir = Array(fetch(:exclude_dir))
|
42
|
+
exclude_args = exclude_dir.map { |dir| "--exclude '#{dir}'"}
|
43
|
+
|
44
|
+
#cmd = "git archive #{tar_verbose} --format=tar.gz --output=#{archive_name} HEAD:#{include_dir}"
|
45
|
+
cmd = ["git ls-files #{include_dir} | tar -c#{tar_verbose}zf #{archive_name} -T -", *exclude_args]
|
46
|
+
puts cmd.join(' ')
|
47
|
+
system cmd.join(' ')
|
48
|
+
|
49
|
+
# cmd = "cd #{include_dir} && git submodule foreach tar --append --file=collection.tar rock"
|
50
|
+
# # "tar -c#{tar_verbose}zf #{archive_name} $(git ls-files)", *exclude_args
|
51
|
+
# puts cmd
|
52
|
+
# system cmd
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
task :clean do
|
57
|
+
archive_name = fetch(:archive_name)
|
58
|
+
File.delete archive_name if File.exists? archive_name
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-scm-localgitcopy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom Hanoldt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
description: A copy strategy for Capistrano 3, which uses `git ls-files` local, tars
|
28
|
+
the files, uploads and extracts.
|
29
|
+
email:
|
30
|
+
- tom@creative-workflow.berlin
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".gitignore"
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- capistrano-scm-localgitcopy.gemspec
|
41
|
+
- lib/capistrano-scm-localgitcopy.rb
|
42
|
+
- lib/capistrano/scm/localgitcopy.rb
|
43
|
+
- lib/capistrano/scm/tasks/localgitcopy.rake
|
44
|
+
homepage: https://github.com/creative-workflow/capistrano-scm-localgitcopy
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata: {}
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 2.6.12
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: A copy strategy for Capistrano 3, which uses `git ls-files` local, tars the
|
68
|
+
files, uploads and extracts.
|
69
|
+
test_files: []
|