capistrano-push_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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 70f28ce34a7223a398170a815ace2f71e9a00786a104a48219962fcdd46d3bbe
4
+ data.tar.gz: 66fc9f4a45d0bbd37a9427158834f3e94768e1ddebc35deacb86bb1ae9e1ef1d
5
+ SHA512:
6
+ metadata.gz: d5f56f42b6c0fcf5678b5fe8830e916e5c830e7ed2b0292ca24fb3a13b2e74786fd213f912c40599d76bcb4a3720934e441ac140055aeee14c9a93684558ebe6
7
+ data.tar.gz: 4db1394b0e3f5874312f6332717ca9ab803acd2b8a15cf8475428c84d2f03e3bc436fb557fdae3b02c08662ce83e9ef14ca616659bfd5a1a8e3dbd7ae8cf8357
data/.gitignore ADDED
@@ -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
data/.rubocop.yml ADDED
@@ -0,0 +1,130 @@
1
+ AllCops:
2
+ Exclude:
3
+ - bin/*
4
+ - node_modules/**/*
5
+ NewCops: enable
6
+
7
+ Gemspec/RequiredRubyVersion:
8
+ Enabled: false
9
+
10
+ Layout/CaseIndentation:
11
+ EnforcedStyle: end
12
+
13
+ Layout/EndAlignment:
14
+ EnforcedStyleAlignWith: variable
15
+
16
+ Layout/LineLength:
17
+ Enabled: false
18
+
19
+ Layout/EmptyLinesAroundAccessModifier:
20
+ EnforcedStyle: only_before
21
+
22
+ Layout/SpaceInLambdaLiteral:
23
+ EnforcedStyle: require_space
24
+
25
+ Layout/SpaceInsideBlockBraces:
26
+ SpaceBeforeBlockParameters: false
27
+
28
+ Layout/SpaceInsideHashLiteralBraces:
29
+ EnforcedStyle: no_space
30
+
31
+ Metrics/AbcSize:
32
+ Enabled: false
33
+
34
+ Metrics/BlockLength:
35
+ Enabled: false
36
+
37
+ Metrics/ClassLength:
38
+ Enabled: false
39
+
40
+ Metrics/CyclomaticComplexity:
41
+ Enabled: false
42
+
43
+ Metrics/MethodLength:
44
+ Enabled: false
45
+
46
+ Metrics/ModuleLength:
47
+ Enabled: false
48
+
49
+ Metrics/PerceivedComplexity:
50
+ Enabled: false
51
+
52
+ Naming/HeredocDelimiterNaming:
53
+ Enabled: false
54
+
55
+ Naming/MethodParameterName:
56
+ Enabled: false
57
+
58
+ Naming/PredicateName:
59
+ Enabled: false
60
+
61
+ Style/Alias:
62
+ EnforcedStyle: prefer_alias_method
63
+
64
+ Style/AsciiComments:
65
+ Enabled: false
66
+
67
+ Style/BlockDelimiters:
68
+ Enabled: false
69
+
70
+ Style/Documentation:
71
+ Enabled: false
72
+
73
+ Style/EmptyCaseCondition:
74
+ Enabled: false
75
+
76
+ Style/EmptyMethod:
77
+ EnforcedStyle: expanded
78
+
79
+ Style/FrozenStringLiteralComment:
80
+ Enabled: false
81
+
82
+ Style/HashSyntax:
83
+ Exclude:
84
+ - Rakefile
85
+ - "**/*.rake"
86
+
87
+ Style/Lambda:
88
+ EnforcedStyle: literal
89
+
90
+ Style/IfUnlessModifier:
91
+ Enabled: false
92
+
93
+ Style/MultilineBlockChain:
94
+ Enabled: false
95
+
96
+ Style/NumericLiterals:
97
+ Enabled: false
98
+
99
+ Style/NumericPredicate:
100
+ Enabled: false
101
+
102
+ Style/PercentLiteralDelimiters:
103
+ PreferredDelimiters:
104
+ '%i': '()'
105
+ '%w': '()'
106
+ '%r': '()'
107
+
108
+ Style/SpecialGlobalVars:
109
+ Enabled: false
110
+
111
+ Style/StringLiterals:
112
+ EnforcedStyle: double_quotes
113
+
114
+ Style/StringLiteralsInInterpolation:
115
+ EnforcedStyle: double_quotes
116
+
117
+ Style/SymbolArray:
118
+ Enabled: false
119
+
120
+ Style/TrailingCommaInArguments:
121
+ EnforcedStyleForMultiline: consistent_comma
122
+
123
+ Style/TrailingCommaInArrayLiteral:
124
+ EnforcedStyleForMultiline: consistent_comma
125
+
126
+ Style/TrailingCommaInHashLiteral:
127
+ EnforcedStyleForMultiline: consistent_comma
128
+
129
+ Style/ZeroLengthPredicate:
130
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.0
6
+ before_install: gem install bundler -v 2.1.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # v0.1.0
2
+
3
+ - Initial release.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in capistrano-push_check.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
8
+ gem "rubocop", "~> 1.16"
data/Gemfile.lock ADDED
@@ -0,0 +1,55 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ capistrano-push_check (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.4.4)
11
+ parallel (1.20.1)
12
+ parser (3.0.1.1)
13
+ ast (~> 2.4.1)
14
+ rainbow (3.0.0)
15
+ rake (12.3.3)
16
+ regexp_parser (2.1.1)
17
+ rexml (3.2.5)
18
+ rspec (3.10.0)
19
+ rspec-core (~> 3.10.0)
20
+ rspec-expectations (~> 3.10.0)
21
+ rspec-mocks (~> 3.10.0)
22
+ rspec-core (3.10.1)
23
+ rspec-support (~> 3.10.0)
24
+ rspec-expectations (3.10.1)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.10.0)
27
+ rspec-mocks (3.10.2)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-support (3.10.2)
31
+ rubocop (1.16.1)
32
+ parallel (~> 1.10)
33
+ parser (>= 3.0.0.0)
34
+ rainbow (>= 2.2.2, < 4.0)
35
+ regexp_parser (>= 1.8, < 3.0)
36
+ rexml
37
+ rubocop-ast (>= 1.7.0, < 2.0)
38
+ ruby-progressbar (~> 1.7)
39
+ unicode-display_width (>= 1.4.0, < 3.0)
40
+ rubocop-ast (1.7.0)
41
+ parser (>= 3.0.1.1)
42
+ ruby-progressbar (1.11.0)
43
+ unicode-display_width (2.0.0)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ capistrano-push_check!
50
+ rake (~> 12.0)
51
+ rspec (~> 3.0)
52
+ rubocop (~> 1.16)
53
+
54
+ BUNDLED WITH
55
+ 2.1.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 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.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # capistrano/push_check
2
+
3
+ This gem check local git branch before all Capistrano tasks, to prevents deployment with unpushed branch.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'capistrano-push_check'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install capistrano-push_check
20
+
21
+ ## Usage
22
+
23
+ Add line below to `Capfile`.
24
+
25
+ ```ruby
26
+ require "capistrano/push_check"
27
+ ```
28
+
29
+ When you run `cap` command (with stage name), checks local branch. And if it is wrong, prints message below and abort deployment.
30
+
31
+ ================================================================================
32
+ !!! Local branch `master` is ahead of upstream by 1 commit(s). !!!
33
+ ================================================================================
34
+
35
+ If you want to skip check, please set `skip_push_check` variable to `true`.
36
+
37
+ ```ruby
38
+ set :skip_push_check, true
39
+ ```
40
+
41
+ ## Development
42
+
43
+ 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.
44
+
45
+ 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).
46
+
47
+ ## Contributing
48
+
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/labocho/capistrano-push_check.
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "capistrano/push_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__)
data/bin/rubocop ADDED
@@ -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")
data/bin/setup ADDED
@@ -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,27 @@
1
+ require_relative "lib/capistrano/push_check/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "capistrano-push_check"
5
+ spec.version = Capistrano::PushCheck::VERSION
6
+ spec.authors = ["labocho"]
7
+ spec.email = ["labocho@penguinlab.jp"]
8
+
9
+ spec.summary = "Checks not pushed commits exists before deployment"
10
+ spec.description = "Checks not pushed commits exists before deployment"
11
+ spec.homepage = "https://github.com/socioart/capistrano-push_check"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = spec.homepage
17
+ spec.metadata["changelog_uri"] = "https://github.com/socioart/capistrano-push_check/blob/master/CHANGELOG.md"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r(^exe/)) {|f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+ 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/push_check/version"
2
+ require "capistrano/push_check/tasks"
@@ -0,0 +1 @@
1
+ load File.expand_path("../tasks/push_check.rake", __dir__)
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module PushCheck
3
+ VERSION = "0.1.0".freeze
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ Capistrano::DSL.stages.each do |stage|
2
+ after stage, "check:push"
3
+ end
4
+
5
+ namespace :check do
6
+ task :push do
7
+ next if fetch(:skip_push_check)
8
+
9
+ local_branch = `git symbolic-ref --short HEAD`.strip
10
+ track = ` git branch --list --format '%(upstream:track)' #{local_branch}`.strip
11
+
12
+ unless track == ""
13
+ track =~ /\[ahead (\d+)\]/
14
+ n = $~.captures.first.to_i
15
+ warn("=" * 80)
16
+ warn("!!! Local branch `#{local_branch}` is ahead of upstream by #{n} commit(s). !!!")
17
+ warn("=" * 80)
18
+ exit 1
19
+ end
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-push_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: 2021-06-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Checks not pushed commits exists before deployment
14
+ email:
15
+ - labocho@penguinlab.jp
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - ".rubocop.yml"
23
+ - ".travis.yml"
24
+ - CHANGELOG.md
25
+ - Gemfile
26
+ - Gemfile.lock
27
+ - LICENSE.txt
28
+ - README.md
29
+ - Rakefile
30
+ - bin/console
31
+ - bin/rubocop
32
+ - bin/setup
33
+ - capistrano-push_check.gemspec
34
+ - lib/capistrano-push_check.rb
35
+ - lib/capistrano/push_check.rb
36
+ - lib/capistrano/push_check/tasks.rb
37
+ - lib/capistrano/push_check/version.rb
38
+ - lib/capistrano/tasks/push_check.rake
39
+ homepage: https://github.com/socioart/capistrano-push_check
40
+ licenses:
41
+ - MIT
42
+ metadata:
43
+ homepage_uri: https://github.com/socioart/capistrano-push_check
44
+ source_code_uri: https://github.com/socioart/capistrano-push_check
45
+ changelog_uri: https://github.com/socioart/capistrano-push_check/blob/master/CHANGELOG.md
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.3.0
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubygems_version: 3.1.2
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Checks not pushed commits exists before deployment
65
+ test_files: []