danger-linear_history 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.rubocop.yml +15 -0
  4. data/Gemfile +4 -0
  5. data/Gemfile.lock +132 -0
  6. data/Guardfile +19 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +23 -0
  9. data/Rakefile +23 -0
  10. data/circle.yml +3 -0
  11. data/danger-linear_history.gemspec +50 -0
  12. data/lib/danger_plugin.rb +39 -0
  13. data/lib/version.rb +3 -0
  14. data/spec/fixtures/linear/COMMIT_EDITMSG +1 -0
  15. data/spec/fixtures/linear/HEAD +1 -0
  16. data/spec/fixtures/linear/MERGE_RR +0 -0
  17. data/spec/fixtures/linear/config +7 -0
  18. data/spec/fixtures/linear/description +1 -0
  19. data/spec/fixtures/linear/hooks/applypatch-msg.sample +15 -0
  20. data/spec/fixtures/linear/hooks/commit-msg.sample +24 -0
  21. data/spec/fixtures/linear/hooks/post-update.sample +8 -0
  22. data/spec/fixtures/linear/hooks/pre-applypatch.sample +14 -0
  23. data/spec/fixtures/linear/hooks/pre-commit.sample +49 -0
  24. data/spec/fixtures/linear/hooks/pre-push.sample +53 -0
  25. data/spec/fixtures/linear/hooks/pre-rebase.sample +169 -0
  26. data/spec/fixtures/linear/hooks/pre-receive.sample +24 -0
  27. data/spec/fixtures/linear/hooks/prepare-commit-msg.sample +36 -0
  28. data/spec/fixtures/linear/hooks/update.sample +128 -0
  29. data/spec/fixtures/linear/index +0 -0
  30. data/spec/fixtures/linear/info/exclude +6 -0
  31. data/spec/fixtures/linear/info/refs +1 -0
  32. data/spec/fixtures/linear/logs/HEAD +3 -0
  33. data/spec/fixtures/linear/logs/refs/heads/master +3 -0
  34. data/spec/fixtures/linear/objects/info/packs +2 -0
  35. data/spec/fixtures/linear/objects/pack/pack-0d11e1d12c122d1872a828e6c2ab3c81ee31b0a3.idx +0 -0
  36. data/spec/fixtures/linear/objects/pack/pack-0d11e1d12c122d1872a828e6c2ab3c81ee31b0a3.pack +0 -0
  37. data/spec/fixtures/linear/packed-refs +2 -0
  38. data/spec/fixtures/nonlinear/COMMIT_EDITMSG +19 -0
  39. data/spec/fixtures/nonlinear/HEAD +1 -0
  40. data/spec/fixtures/nonlinear/MERGE_RR +0 -0
  41. data/spec/fixtures/nonlinear/ORIG_HEAD +1 -0
  42. data/spec/fixtures/nonlinear/config +7 -0
  43. data/spec/fixtures/nonlinear/description +1 -0
  44. data/spec/fixtures/nonlinear/hooks/applypatch-msg.sample +15 -0
  45. data/spec/fixtures/nonlinear/hooks/commit-msg.sample +24 -0
  46. data/spec/fixtures/nonlinear/hooks/post-update.sample +8 -0
  47. data/spec/fixtures/nonlinear/hooks/pre-applypatch.sample +14 -0
  48. data/spec/fixtures/nonlinear/hooks/pre-commit.sample +49 -0
  49. data/spec/fixtures/nonlinear/hooks/pre-push.sample +53 -0
  50. data/spec/fixtures/nonlinear/hooks/pre-rebase.sample +169 -0
  51. data/spec/fixtures/nonlinear/hooks/pre-receive.sample +24 -0
  52. data/spec/fixtures/nonlinear/hooks/prepare-commit-msg.sample +36 -0
  53. data/spec/fixtures/nonlinear/hooks/update.sample +128 -0
  54. data/spec/fixtures/nonlinear/index +0 -0
  55. data/spec/fixtures/nonlinear/info/exclude +6 -0
  56. data/spec/fixtures/nonlinear/info/refs +1 -0
  57. data/spec/fixtures/nonlinear/logs/HEAD +8 -0
  58. data/spec/fixtures/nonlinear/logs/refs/heads/master +5 -0
  59. data/spec/fixtures/nonlinear/objects/c4/502db7a73cfd334e9c1ab3988fbb7e3c2560bf +0 -0
  60. data/spec/fixtures/nonlinear/objects/info/packs +2 -0
  61. data/spec/fixtures/nonlinear/objects/pack/pack-c15a48c606d589bebf788e824ec15946ddc2171b.idx +0 -0
  62. data/spec/fixtures/nonlinear/objects/pack/pack-c15a48c606d589bebf788e824ec15946ddc2171b.pack +0 -0
  63. data/spec/fixtures/nonlinear/packed-refs +2 -0
  64. data/spec/fixtures/nonlinear/rr-cache/b5af61297bb440010b5deb18d272d0976716bc1f/postimage +3 -0
  65. data/spec/fixtures/nonlinear/rr-cache/b5af61297bb440010b5deb18d272d0976716bc1f/preimage +6 -0
  66. data/spec/linear_history_spec.rb +83 -0
  67. data/spec/spec_helper.rb +59 -0
  68. metadata +304 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b8a9b163daf733675fdad5119a9e2848e0a24460
4
+ data.tar.gz: 6b4f17cbe8fb8843b3e909c0ecb54eb05eb28937
5
+ SHA512:
6
+ metadata.gz: 1589964249937f149be6636f25b1e91ca9bebed15fbc040dfbc97c4401591b6062cd2bd19b87d4a1422002b665e65abb34cce9f4d5f1611647164ee2bd18e47f
7
+ data.tar.gz: 048c777eebe5c2f76591d06333b9cc680faf19892f72d4ed7ddbc8c5d5f5b5f178a2cfe32532d6267d5fabcd1b7f23f33f37bed3ae3c4e4f3d96d4e7ff140e00
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ .bundle/
5
+ .yardoc/
data/.rubocop.yml ADDED
@@ -0,0 +1,15 @@
1
+ Metrics/BlockLength:
2
+ Enabled: false
3
+
4
+ Style/Documentation:
5
+ Exclude:
6
+ - 'spec/**/*'
7
+ - 'test/**/*'
8
+
9
+ Style/GuardClause:
10
+ Exclude:
11
+ - 'lib/danger_plugin.rb'
12
+
13
+ Style/SignalException:
14
+ Exclude:
15
+ - 'lib/danger_plugin.rb'
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-linear_history.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,132 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danger-linear_history (0.0.1)
5
+ danger-plugin-api (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.5.1)
11
+ public_suffix (~> 2.0, >= 2.0.2)
12
+ ast (2.3.0)
13
+ claide (1.0.1)
14
+ claide-plugins (0.9.2)
15
+ cork
16
+ nap
17
+ open4 (~> 1.3)
18
+ coderay (1.1.1)
19
+ colored2 (3.1.2)
20
+ cork (0.3.0)
21
+ colored2 (~> 3.1)
22
+ danger (5.0.0)
23
+ claide (~> 1.0)
24
+ claide-plugins (>= 0.9.2)
25
+ colored2 (~> 3.1)
26
+ cork (~> 0.1)
27
+ faraday (~> 0.9)
28
+ faraday-http-cache (~> 1.0)
29
+ git (~> 1)
30
+ kramdown (~> 1.5)
31
+ octokit (~> 4.2)
32
+ terminal-table (~> 1)
33
+ danger-plugin-api (1.0.0)
34
+ danger (> 2.0)
35
+ diff-lcs (1.3)
36
+ faraday (0.12.0.1)
37
+ multipart-post (>= 1.2, < 3)
38
+ faraday-http-cache (1.3.1)
39
+ faraday (~> 0.8)
40
+ ffi (1.9.18)
41
+ formatador (0.2.5)
42
+ git (1.3.0)
43
+ guard (2.14.1)
44
+ formatador (>= 0.2.4)
45
+ listen (>= 2.7, < 4.0)
46
+ lumberjack (~> 1.0)
47
+ nenv (~> 0.1)
48
+ notiffany (~> 0.0)
49
+ pry (>= 0.9.12)
50
+ shellany (~> 0.0)
51
+ thor (>= 0.18.1)
52
+ guard-compat (1.2.1)
53
+ guard-rspec (4.7.3)
54
+ guard (~> 2.1)
55
+ guard-compat (~> 1.1)
56
+ rspec (>= 2.99.0, < 4.0)
57
+ kramdown (1.13.2)
58
+ listen (3.0.7)
59
+ rb-fsevent (>= 0.9.3)
60
+ rb-inotify (>= 0.9.7)
61
+ lumberjack (1.0.11)
62
+ method_source (0.8.2)
63
+ multipart-post (2.0.0)
64
+ nap (1.1.0)
65
+ nenv (0.3.0)
66
+ notiffany (0.1.1)
67
+ nenv (~> 0.1)
68
+ shellany (~> 0.0)
69
+ octokit (4.7.0)
70
+ sawyer (~> 0.8.0, >= 0.5.3)
71
+ open4 (1.3.4)
72
+ parser (2.4.0.0)
73
+ ast (~> 2.2)
74
+ powerpack (0.1.1)
75
+ pry (0.10.4)
76
+ coderay (~> 1.1.0)
77
+ method_source (~> 0.8.1)
78
+ slop (~> 3.4)
79
+ public_suffix (2.0.5)
80
+ rainbow (2.2.1)
81
+ rake (10.5.0)
82
+ rb-fsevent (0.9.8)
83
+ rb-inotify (0.9.8)
84
+ ffi (>= 0.5.0)
85
+ rspec (3.5.0)
86
+ rspec-core (~> 3.5.0)
87
+ rspec-expectations (~> 3.5.0)
88
+ rspec-mocks (~> 3.5.0)
89
+ rspec-core (3.5.4)
90
+ rspec-support (~> 3.5.0)
91
+ rspec-expectations (3.5.0)
92
+ diff-lcs (>= 1.2.0, < 2.0)
93
+ rspec-support (~> 3.5.0)
94
+ rspec-mocks (3.5.0)
95
+ diff-lcs (>= 1.2.0, < 2.0)
96
+ rspec-support (~> 3.5.0)
97
+ rspec-support (3.5.0)
98
+ rubocop (0.48.1)
99
+ parser (>= 2.3.3.1, < 3.0)
100
+ powerpack (~> 0.1)
101
+ rainbow (>= 1.99.1, < 3.0)
102
+ ruby-progressbar (~> 1.7)
103
+ unicode-display_width (~> 1.0, >= 1.0.1)
104
+ ruby-progressbar (1.8.1)
105
+ sawyer (0.8.1)
106
+ addressable (>= 2.3.5, < 2.6)
107
+ faraday (~> 0.8, < 1.0)
108
+ shellany (0.0.1)
109
+ slop (3.6.0)
110
+ terminal-table (1.7.3)
111
+ unicode-display_width (~> 1.1.1)
112
+ thor (0.19.4)
113
+ unicode-display_width (1.1.3)
114
+ yard (0.9.8)
115
+
116
+ PLATFORMS
117
+ ruby
118
+
119
+ DEPENDENCIES
120
+ bundler (~> 1.3)
121
+ danger-linear_history!
122
+ guard (~> 2.14)
123
+ guard-rspec (~> 4.7)
124
+ listen (= 3.0.7)
125
+ pry
126
+ rake (~> 10.0)
127
+ rspec (~> 3.4)
128
+ rubocop (~> 0.41)
129
+ yard (~> 0.8)
130
+
131
+ BUNDLED WITH
132
+ 1.14.3
data/Guardfile ADDED
@@ -0,0 +1,19 @@
1
+ # A guardfile for making Danger Plugins
2
+ # For more info see https://github.com/guard/guard#readme
3
+
4
+ # To run, use `bundle exec guard`.
5
+
6
+ guard :rspec, cmd: 'bundle exec rspec' do
7
+ require 'guard/rspec/dsl'
8
+ dsl = Guard::RSpec::Dsl.new(self)
9
+
10
+ # RSpec files
11
+ rspec = dsl.rspec
12
+ watch(rspec.spec_helper) { rspec.spec_dir }
13
+ watch(rspec.spec_support) { rspec.spec_dir }
14
+ watch(rspec.spec_files)
15
+
16
+ # Ruby files
17
+ ruby = dsl.ruby
18
+ dsl.watch_spec_files_for(ruby.lib_files)
19
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2017 Alexsander Akers <me@a2.io>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # danger-linear_history
2
+
3
+ Enforce linear history inside your project.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ $ gem install danger-linear_history
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ruby
14
+ linear_history.validate!
15
+ ```
16
+
17
+ ## Development
18
+
19
+ 1. Clone this repo
20
+ 2. Run `bundle install` to setup dependencies.
21
+ 3. Run `bundle exec rake spec` to run the tests.
22
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
23
+ 5. Make your changes.
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:specs)
6
+
7
+ task default: :specs
8
+
9
+ task :spec do
10
+ Rake::Task['specs'].invoke
11
+ Rake::Task['rubocop'].invoke
12
+ Rake::Task['spec_docs'].invoke
13
+ end
14
+
15
+ desc 'Run RuboCop on the lib/specs directory'
16
+ RuboCop::RakeTask.new(:rubocop) do |task|
17
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
18
+ end
19
+
20
+ desc 'Ensure that the plugin passes `danger plugins lint`'
21
+ task :spec_docs do
22
+ sh 'bundle exec danger plugins lint'
23
+ end
data/circle.yml ADDED
@@ -0,0 +1,3 @@
1
+ test:
2
+ override:
3
+ - bundle exec rake spec
@@ -0,0 +1,50 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'danger-linear_history'
9
+ spec.version = LinearHistory::VERSION
10
+ spec.authors = ['Alexsander Akers']
11
+ spec.email = ['me@a2.io']
12
+ spec.description = 'A short description of danger-linear_history.'
13
+ spec.summary = 'A longer description of danger-linear_history.'
14
+ spec.homepage = 'https://github.com/a2/danger-linear_history'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
23
+
24
+ # General ruby development
25
+ spec.add_development_dependency 'bundler', '~> 1.3'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+
28
+ # Testing support
29
+ spec.add_development_dependency 'rspec', '~> 3.4'
30
+
31
+ # Linting code and docs
32
+ spec.add_development_dependency 'rubocop', '~> 0.41'
33
+ spec.add_development_dependency 'yard', '~> 0.8'
34
+
35
+ # Makes testing easy via `bundle exec guard`
36
+ spec.add_development_dependency 'guard', '~> 2.14'
37
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
38
+
39
+ # If you want to work on older builds of ruby
40
+ spec.add_development_dependency 'listen', '3.0.7'
41
+
42
+ # This gives you the chance to run a REPL inside your tests
43
+ # via:
44
+ #
45
+ # require 'pry'
46
+ # binding.pry
47
+ #
48
+ # This will stop test execution and let you inspect the results
49
+ spec.add_development_dependency 'pry'
50
+ end
@@ -0,0 +1,39 @@
1
+ module Danger
2
+ # Enforce linear history inside your project.
3
+ #
4
+ # @example Running with warnings
5
+ #
6
+ # # Enforces linear history, but does not fail the pull request
7
+ # # linear_history.validate!(soft_fail: true)
8
+ # linear_history.validate!
9
+ #
10
+ # @example Running with errors
11
+ #
12
+ # # Enforces linear history, failing the pull request if applicable
13
+ # linear_history.validate!(soft_fail: false)
14
+ #
15
+ # @see tootbot/tootbot
16
+ # @tags git
17
+ #
18
+ class LinearHistory < Plugin
19
+ # Validates the pull request commits to ensure linear history.
20
+ #
21
+ # @param [Bool] soft_fail
22
+ # Toggles output behavior between warn and fail.
23
+ # Defaults to true (warn).
24
+ #
25
+ # @return [void]
26
+ #
27
+ def validate!(soft_fail: true)
28
+ return unless commits.any? { |commit| commit.parents.length > 1 }
29
+
30
+ message = 'Please rebase to get rid of the merge commits in this PR'
31
+
32
+ if soft_fail
33
+ warn message
34
+ else
35
+ fail message
36
+ end
37
+ end
38
+ end
39
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module LinearHistory
2
+ VERSION = '0.0.1'.freeze
3
+ end
@@ -0,0 +1 @@
1
+ C
@@ -0,0 +1 @@
1
+ ref: refs/heads/master
File without changes
@@ -0,0 +1,7 @@
1
+ [core]
2
+ repositoryformatversion = 0
3
+ filemode = true
4
+ bare = false
5
+ logallrefupdates = true
6
+ ignorecase = true
7
+ precomposeunicode = true
@@ -0,0 +1 @@
1
+ Unnamed repository; edit this file 'description' to name the repository.
@@ -0,0 +1,15 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script to check the commit log message taken by
4
+ # applypatch from an e-mail message.
5
+ #
6
+ # The hook should exit with non-zero status after issuing an
7
+ # appropriate message if it wants to stop the commit. The hook is
8
+ # allowed to edit the commit message file.
9
+ #
10
+ # To enable this hook, rename this file to "applypatch-msg".
11
+
12
+ . git-sh-setup
13
+ commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
14
+ test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
15
+ :
@@ -0,0 +1,24 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script to check the commit log message.
4
+ # Called by "git commit" with one argument, the name of the file
5
+ # that has the commit message. The hook should exit with non-zero
6
+ # status after issuing an appropriate message if it wants to stop the
7
+ # commit. The hook is allowed to edit the commit message file.
8
+ #
9
+ # To enable this hook, rename this file to "commit-msg".
10
+
11
+ # Uncomment the below to add a Signed-off-by line to the message.
12
+ # Doing this in a hook is a bad idea in general, but the prepare-commit-msg
13
+ # hook is more suited to it.
14
+ #
15
+ # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
16
+ # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
17
+
18
+ # This example catches duplicate Signed-off-by lines.
19
+
20
+ test "" = "$(grep '^Signed-off-by: ' "$1" |
21
+ sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
22
+ echo >&2 Duplicate Signed-off-by lines.
23
+ exit 1
24
+ }
@@ -0,0 +1,8 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script to prepare a packed repository for use over
4
+ # dumb transports.
5
+ #
6
+ # To enable this hook, rename this file to "post-update".
7
+
8
+ exec git update-server-info
@@ -0,0 +1,14 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script to verify what is about to be committed
4
+ # by applypatch from an e-mail message.
5
+ #
6
+ # The hook should exit with non-zero status after issuing an
7
+ # appropriate message if it wants to stop the commit.
8
+ #
9
+ # To enable this hook, rename this file to "pre-applypatch".
10
+
11
+ . git-sh-setup
12
+ precommit="$(git rev-parse --git-path hooks/pre-commit)"
13
+ test -x "$precommit" && exec "$precommit" ${1+"$@"}
14
+ :