capistrano-local_branch_check 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1e4195f8533706b31a6e5a8d3139179a3ea70ef8d08fbfd2e283fb751a4d2577
4
+ data.tar.gz: 59cece41176f956a477fd8952f0ab62f0cd48a782f3977329c0cb7123bf3d7dc
5
+ SHA512:
6
+ metadata.gz: fe7466bd6146592e7efc588f1071fb236dec93d9ebcd2517c571262b1877112b6fef0ca71f87e8305fa4a18c8f67aa9fddc6391784407f25ac818a54c7598583
7
+ data.tar.gz: adc39a7235e926400a8072f4ca31ee97de883cd89529039aef3b85f3d67fe8b0a6589d6f3502271e6cd4df94028600bbd8dd341af52dc68c087f682c6bbd226d
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,126 @@
1
+ AllCops:
2
+ Exclude:
3
+ - bin/*
4
+ - node_modules/**/*
5
+
6
+ Layout/CaseIndentation:
7
+ EnforcedStyle: end
8
+
9
+ Layout/EndAlignment:
10
+ EnforcedStyleAlignWith: variable
11
+
12
+ Layout/LineLength:
13
+ Enabled: false
14
+
15
+ Layout/EmptyLinesAroundAccessModifier:
16
+ EnforcedStyle: only_before
17
+
18
+ Layout/SpaceInLambdaLiteral:
19
+ EnforcedStyle: require_space
20
+
21
+ Layout/SpaceInsideBlockBraces:
22
+ SpaceBeforeBlockParameters: false
23
+
24
+ Layout/SpaceInsideHashLiteralBraces:
25
+ EnforcedStyle: no_space
26
+
27
+ Metrics/AbcSize:
28
+ Enabled: false
29
+
30
+ Metrics/BlockLength:
31
+ Enabled: false
32
+
33
+ Metrics/ClassLength:
34
+ Enabled: false
35
+
36
+ Metrics/CyclomaticComplexity:
37
+ Enabled: false
38
+
39
+ Metrics/MethodLength:
40
+ Enabled: false
41
+
42
+ Metrics/ModuleLength:
43
+ Enabled: false
44
+
45
+ Metrics/PerceivedComplexity:
46
+ Enabled: false
47
+
48
+ Naming/HeredocDelimiterNaming:
49
+ Enabled: false
50
+
51
+ Naming/MethodParameterName:
52
+ Enabled: false
53
+
54
+ Naming/PredicateName:
55
+ Enabled: false
56
+
57
+ Style/Alias:
58
+ EnforcedStyle: prefer_alias_method
59
+
60
+ Style/AsciiComments:
61
+ Enabled: false
62
+
63
+ Style/BlockDelimiters:
64
+ Enabled: false
65
+
66
+ Style/Documentation:
67
+ Enabled: false
68
+
69
+ Style/EmptyCaseCondition:
70
+ Enabled: false
71
+
72
+ Style/EmptyMethod:
73
+ EnforcedStyle: expanded
74
+
75
+ Style/FrozenStringLiteralComment:
76
+ Enabled: false
77
+
78
+ Style/HashSyntax:
79
+ Exclude:
80
+ - Rakefile
81
+ - "**/*.rake"
82
+
83
+ Style/Lambda:
84
+ EnforcedStyle: literal
85
+
86
+ Style/IfUnlessModifier:
87
+ Enabled: false
88
+
89
+ Style/MultilineBlockChain:
90
+ Enabled: false
91
+
92
+ Style/NumericLiterals:
93
+ Enabled: false
94
+
95
+ Style/NumericPredicate:
96
+ Enabled: false
97
+
98
+ Style/PercentLiteralDelimiters:
99
+ PreferredDelimiters:
100
+ '%i': '()'
101
+ '%w': '()'
102
+ '%r': '()'
103
+
104
+ Style/SpecialGlobalVars:
105
+ Enabled: false
106
+
107
+ Style/StringLiterals:
108
+ EnforcedStyle: double_quotes
109
+
110
+ Style/StringLiteralsInInterpolation:
111
+ EnforcedStyle: double_quotes
112
+
113
+ Style/SymbolArray:
114
+ Enabled: false
115
+
116
+ Style/TrailingCommaInArguments:
117
+ EnforcedStyleForMultiline: consistent_comma
118
+
119
+ Style/TrailingCommaInArrayLiteral:
120
+ EnforcedStyleForMultiline: consistent_comma
121
+
122
+ Style/TrailingCommaInHashLiteral:
123
+ EnforcedStyleForMultiline: consistent_comma
124
+
125
+ Style/ZeroLengthPredicate:
126
+ Enabled: false
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.4
7
+ before_install: gem install bundler -v 2.0.2
@@ -0,0 +1,3 @@
1
+ # v0.1.0
2
+
3
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in capistrano-local_branch_check.gemspec
4
+ gemspec
@@ -0,0 +1,70 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ capistrano-local_branch_check (0.1.0)
5
+ capistrano (>= 3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ airbrussh (1.4.0)
11
+ sshkit (>= 1.6.1, != 1.7.0)
12
+ ast (2.4.0)
13
+ capistrano (3.12.0)
14
+ airbrussh (>= 1.0.0)
15
+ i18n
16
+ rake (>= 10.0.0)
17
+ sshkit (>= 1.9.0)
18
+ concurrent-ruby (1.1.6)
19
+ diff-lcs (1.3)
20
+ i18n (1.8.2)
21
+ concurrent-ruby (~> 1.0)
22
+ jaro_winkler (1.5.4)
23
+ net-scp (2.0.0)
24
+ net-ssh (>= 2.6.5, < 6.0.0)
25
+ net-ssh (5.2.0)
26
+ parallel (1.19.1)
27
+ parser (2.7.0.2)
28
+ ast (~> 2.4.0)
29
+ rainbow (3.0.0)
30
+ rake (10.5.0)
31
+ rexml (3.2.4)
32
+ rspec (3.9.0)
33
+ rspec-core (~> 3.9.0)
34
+ rspec-expectations (~> 3.9.0)
35
+ rspec-mocks (~> 3.9.0)
36
+ rspec-core (3.9.1)
37
+ rspec-support (~> 3.9.1)
38
+ rspec-expectations (3.9.0)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.9.0)
41
+ rspec-mocks (3.9.1)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.9.0)
44
+ rspec-support (3.9.2)
45
+ rubocop (0.80.0)
46
+ jaro_winkler (~> 1.5.1)
47
+ parallel (~> 1.10)
48
+ parser (>= 2.7.0.1)
49
+ rainbow (>= 2.2.2, < 4.0)
50
+ rexml
51
+ ruby-progressbar (~> 1.7)
52
+ unicode-display_width (>= 1.4.0, < 1.7)
53
+ ruby-progressbar (1.10.1)
54
+ sshkit (1.20.0)
55
+ net-scp (>= 1.1.2)
56
+ net-ssh (>= 2.8.0)
57
+ unicode-display_width (1.6.1)
58
+
59
+ PLATFORMS
60
+ ruby
61
+
62
+ DEPENDENCIES
63
+ bundler (~> 2.0)
64
+ capistrano-local_branch_check!
65
+ rake (~> 10.0)
66
+ rspec (~> 3.0)
67
+ rubocop (~> 0.80.0)
68
+
69
+ BUNDLED WITH
70
+ 2.0.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 labocho
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,61 @@
1
+ # capistrano/local_branch_check
2
+
3
+ This gem check local git branch before all Capistrano tasks, to prevents deployment in wrong branch (that branch may contain unexpected deploy configurations).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'capistrano-local_branch_check'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install capistrano-local_branch_check
20
+
21
+ ## Usage
22
+
23
+ Add line below to `Capifile`.
24
+
25
+ ```ruby
26
+ require "capistrano/local_branch_check"
27
+ ```
28
+
29
+ If local branch is equal to release branch, no configuration required.
30
+ If local branch is differ from release branch, please set `local_branch` variable like below.
31
+
32
+ ```ruby
33
+ set :branch, "v2"
34
+ set :local_branch, "master"
35
+ ```
36
+
37
+ When you run `cap` command (with stage name), checks local branch. And if it is wrong, prints message below and abort deployment.
38
+
39
+ ================================================================================
40
+ !!! Local branch `master` maybe wrong. Please `git checkout release`. !!!
41
+ ================================================================================
42
+
43
+ If you want to skip check, please set `skip_local_branch_check` variable to `true`.
44
+
45
+ ```ruby
46
+ set :skip_local_branch_check, true
47
+ ```
48
+
49
+ ## Development
50
+
51
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
52
+
53
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/labocho/capistrano-local_branch_check.
58
+
59
+ ## License
60
+
61
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "capistrano/local_branch_check"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rubocop", "rubocop")
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "capistrano/local_branch_check/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "capistrano-local_branch_check"
7
+ spec.version = Capistrano::LocalBranchCheck::VERSION
8
+ spec.authors = ["labocho"]
9
+ spec.email = ["labocho@penguinlab.jp"]
10
+
11
+ spec.summary = "Add checking local git branch before all Capistrano tasks"
12
+ spec.description = "Add checking local git branch before all Capistrano tasks"
13
+ spec.homepage = "https://github.com/socioart/capistrano-local_branch_check"
14
+ spec.license = "MIT"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/socioart/capistrano-local_branch_check"
18
+ spec.metadata["changelog_uri"] = "https://github.com/socioart/capistrano-local_branch_check/blob/master/CHAGELOG.md"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r(^exe/)) {|f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency "capistrano", ">= 3"
30
+
31
+ spec.add_development_dependency "bundler", "~> 2.0"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+ spec.add_development_dependency "rubocop", "~> 0.80.0"
35
+ end
@@ -0,0 +1,3 @@
1
+ # rubocop:disable Naming/FileName
2
+ # If loaded by `Bundler.require`, do nothing.
3
+ # rubocop:enable Naming/FileName
@@ -0,0 +1,2 @@
1
+ require "capistrano/local_branch_check/version"
2
+ require "capistrano/local_branch_check/tasks"
@@ -0,0 +1 @@
1
+ load File.expand_path("../tasks/local_branch_check.rake", __dir__)
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module LocalBranchCheck
3
+ VERSION = "0.1.0".freeze
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ Capistrano::DSL.stages.each do |stage|
2
+ after stage, "check:local_branch"
3
+ end
4
+
5
+ namespace :check do
6
+ task :local_branch do
7
+ next if fetch(:skip_local_branch_check)
8
+
9
+ expected_local_branch = fetch(:local_branch) || fetch(:branch) || raise("Please set `local_branch` or `branch`")
10
+ actual_local_branch = `git symbolic-ref --short HEAD`.strip
11
+
12
+ unless actual_local_branch == expected_local_branch
13
+ warn("=" * 80)
14
+ warn("!!! Local branch `#{actual_local_branch}` maybe wrong. Please `git checkout #{expected_local_branch}`. !!!")
15
+ warn("=" * 80)
16
+ exit 1
17
+ end
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-local_branch_check
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - labocho
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-02-21 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'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.80.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.80.0
83
+ description: Add checking local git branch before all Capistrano tasks
84
+ email:
85
+ - labocho@penguinlab.jp
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".rubocop.yml"
93
+ - ".travis.yml"
94
+ - CHANGELOG.md
95
+ - Gemfile
96
+ - Gemfile.lock
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - bin/console
101
+ - bin/rubocop
102
+ - bin/setup
103
+ - capistrano-local_branch_check.gemspec
104
+ - lib/capistrano-local_branch_check.rb
105
+ - lib/capistrano/local_branch_check.rb
106
+ - lib/capistrano/local_branch_check/tasks.rb
107
+ - lib/capistrano/local_branch_check/version.rb
108
+ - lib/capistrano/tasks/local_branch_check.rake
109
+ homepage: https://github.com/socioart/capistrano-local_branch_check
110
+ licenses:
111
+ - MIT
112
+ metadata:
113
+ homepage_uri: https://github.com/socioart/capistrano-local_branch_check
114
+ source_code_uri: https://github.com/socioart/capistrano-local_branch_check
115
+ changelog_uri: https://github.com/socioart/capistrano-local_branch_check/blob/master/CHAGELOG.md
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubygems_version: 3.0.3
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: Add checking local git branch before all Capistrano tasks
135
+ test_files: []