capistrano-uptodate 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # capistrano-uptodate
2
+
3
+ capistrano-uptodate is [capistrano](https://github.com/capistrano/capistrano) extension that automatically check your local repository with remote repository and if repository is not up-to-date:
4
+
5
+ * display corresponding message.
6
+ * ask to confirm recipe execution or abort recipe execution.
7
+
8
+ If you want to be sure that every developer in your team use recent version of deployment recipes before it starts deploy this extension might be handy.
9
+
10
+ ## Installation
11
+
12
+ gem install capistrano-uptodate
13
+
14
+ Add to `Capfile` or `config/deploy.rb`:
15
+
16
+ require 'capistrano/uptodate'
17
+
18
+ ## Configuration
19
+
20
+ You can tune *uptodate* recipe using next options:
21
+
22
+ * *:uptodate_scm* (:git) - SCM you use
23
+ * *:uptodate_scm_bynary* ('git') - path to SCM binary
24
+ * *:uptodate_remote_repository* ('origin') - remote repository
25
+ * *:uptodate_branch* ('master') - branch of repository to check
26
+ * *:uptodate_time* (60) - time in seconds for checking remote repository
27
+ * *:uptodate_behaviour* - (:confirm)
28
+ * *:confirm* - show outdated message and ask to confirm the further execution
29
+ * *:abort* - show outdated message and abort further execution
30
+
31
+ ## Example
32
+
33
+ $ cap production deploy
34
+ triggering load callbacks
35
+ * == Currently executing `uptodate'
36
+ * == Currently executing `uptodate:git'
37
+ Local 'master' branch is not synchronized with 'origin' repository.
38
+ Continue anyway? (y/N)
39
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "capistrano-uptodate"
6
+ s.version = "0.0.1"
7
+ s.authors = ["Andriy Yanko"]
8
+ s.email = ["andriy.yanko@gmail.com"]
9
+ s.homepage = "https://github.com/railsware/capistrano-uptodate"
10
+ s.summary = %q{Capistrano extension that automatically check local repository with remote repository}
11
+
12
+ s.rubyforge_project = "capistrano-uptodate"
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
+ s.add_runtime_dependency "capistrano", ">=2.5.5"
20
+ end
@@ -0,0 +1,49 @@
1
+ Capistrano::Configuration.instance.load do
2
+
3
+ scm = fetch(:uptodate_scm, :git)
4
+ scm_binary = fetch(:uptodate_scm_bynary, 'git')
5
+ remote_repository = fetch(:uptodate_remote_repository, 'origin')
6
+ branch = fetch(:uptodate_branch, 'master')
7
+ time = fetch(:uptodate_time, 300)
8
+ behavior = fetch(:uptodate_behaviour, :confirm)
9
+
10
+ namespace :uptodate do
11
+ desc "Automatically synchronize current repository"
12
+ task :default do
13
+ case scm
14
+ when :git
15
+ top.uptodate.git
16
+ else
17
+ abort("SCM #{scm} is not supported by capistrano/uptodate")
18
+ end
19
+ end
20
+
21
+ task :git do
22
+ git_dir = fetch(:uptodate_local_reposytory, `#{scm_binary} rev-parse --git-dir`.strip)
23
+ abort "Can't detect git repository" if git_dir.empty?
24
+
25
+ fetch_file = File.join(git_dir, "FETCH_HEAD")
26
+
27
+ unless File.exist?(fetch_file) && Time.now - File.mtime(fetch_file) < time
28
+ Capistrano::CLI.ui.say "Fetching references from #{repository} repository ..."
29
+ system("#{scm_binary} fetch #{remote_repository}")
30
+ end
31
+
32
+ local_commit = `#{scm_binary} rev-parse #{branch}`.strip
33
+ remote_commit = `#{scm_binary} rev-parse #{remote_repository}/#{branch}`.strip
34
+
35
+ if local_commit != remote_commit
36
+ Capistrano::CLI.ui.say "Local '#{branch}' branch is not synchronized with '#{remote_repository}' repository."
37
+
38
+ case behavior
39
+ when :confirm
40
+ Capistrano::CLI.ui.ask("Continue anyway? (y/N)") == 'y' or abort
41
+ else
42
+ abort
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ on :load, 'uptodate'
49
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-uptodate
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Andriy Yanko
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-02 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: capistrano
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 17
29
+ segments:
30
+ - 2
31
+ - 5
32
+ - 5
33
+ version: 2.5.5
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description:
37
+ email:
38
+ - andriy.yanko@gmail.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - .gitignore
47
+ - README.md
48
+ - Rakefile
49
+ - capistrano-uptodate.gemspec
50
+ - lib/capistrano/uptodate.rb
51
+ homepage: https://github.com/railsware/capistrano-uptodate
52
+ licenses: []
53
+
54
+ post_install_message:
55
+ rdoc_options: []
56
+
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ requirements: []
78
+
79
+ rubyforge_project: capistrano-uptodate
80
+ rubygems_version: 1.8.6
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: Capistrano extension that automatically check local repository with remote repository
84
+ test_files: []
85
+