danger-android_version_change 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 23ca31f593cedee62a2cf6022675f7edb4f60a80b65ba503bde17faa5a9bd3e1
4
+ data.tar.gz: cd6b3ba0136c8c766e681531ec0af6fdb6b6628f11d742b7a9868698a75cd2d0
5
+ SHA512:
6
+ metadata.gz: 9b6c557b856fe751c15bd01a0b9b0fe342e5034fb9dbc12bdc25c7e8953173c29656a279465327f79dfec3336e7ed855cf876302b9c88fbd773d6d2caa68a526
7
+ data.tar.gz: 837f79b58cbe0a78ad9ea53a46ef77541524d6f4e9f47443fb0b14e99d1e9cfa025712a79666568c47030d30c8377b90a77e6b4a6ffa568a8a2e82ea3ceecfa4
@@ -0,0 +1,95 @@
1
+ version: 2
2
+ jobs:
3
+ dependencies:
4
+ working_directory: ~/code
5
+ docker:
6
+ - image: circleci/ruby:2.3
7
+ steps:
8
+ - checkout
9
+ - restore_cache:
10
+ key: Gemfile-{{ checksum "Gemfile.lock" }}
11
+ - run:
12
+ name: Bundle Install
13
+ command: bundle install --path vendor/bundle
14
+ - type: cache-save
15
+ name: Store bundle cache
16
+ key: Gemfile-{{ checksum "Gemfile.lock" }}
17
+ paths:
18
+ - vendor/bundle
19
+ danger:
20
+ docker:
21
+ - image: dantoml/danger:latest
22
+ steps:
23
+ - checkout
24
+ - run: ./assert_danger_running_on_pr.sh
25
+ - run: bundle install
26
+ - run: '[ ! -z $DANGER_GITHUB_API_TOKEN ] && danger || echo "Skipping Danger for External Contributor"'
27
+ test-lint:
28
+ working_directory: ~/code
29
+ docker:
30
+ - image: circleci/ruby:2.3
31
+ steps:
32
+ - checkout
33
+ - restore_cache:
34
+ key: Gemfile-{{ checksum "Gemfile.lock" }}
35
+ - run:
36
+ name: Bundle Install
37
+ command: bundle install --path vendor/bundle
38
+ - run:
39
+ name: run tests and lint
40
+ command: bundle exec rake spec
41
+ - store_test_results:
42
+ path: test_results
43
+ - run:
44
+ name: Danger lint to make sure it can be published
45
+ command: bundle exec danger plugins lint
46
+ build-gem:
47
+ working_directory: ~/code
48
+ docker:
49
+ - image: circleci/ruby:2.3
50
+ steps:
51
+ - checkout
52
+ - restore_cache:
53
+ key: Gemfile-{{ checksum "Gemfile.lock" }}
54
+ - run:
55
+ name: Bundle Install
56
+ command: bundle install --path vendor/bundle
57
+ - run: gem build danger-android_version_change.gemspec
58
+ deploy:
59
+ working_directory: ~/code
60
+ docker:
61
+ - image: circleci/ruby:2.3
62
+ steps:
63
+ - checkout
64
+ - restore_cache:
65
+ key: Gemfile-{{ checksum "Gemfile.lock" }}
66
+ - run:
67
+ name: Bundle Install
68
+ command: bundle install --path vendor/bundle
69
+ - run:
70
+ name: Generate README.md docs
71
+ command: rm README.md; cat README_header.md > README.md; bundle exec danger plugins readme >> README.md; cat README_footer.md >> README.md
72
+ - run:
73
+ name: Create rubygems credientials file
74
+ command: mkdir ~/.gem; printf "%s\n%s " "---" ":rubygems_api_key:" > ~/.gem/credentials; printf $RUBYGEMS_KEY >> ~/.gem/credentials;chmod 0600 ~/.gem/credentials
75
+ - run: gem build danger-android_version_change.gemspec; gem push danger-android_version_change*.gem
76
+ workflows:
77
+ version: 2
78
+ test-lint:
79
+ jobs:
80
+ - danger
81
+ - dependencies
82
+ - test-lint:
83
+ requires:
84
+ - dependencies
85
+ - build-gem:
86
+ requires:
87
+ - test-lint
88
+ deploy:
89
+ jobs:
90
+ - deploy:
91
+ filters: # Only runs for tags.
92
+ tags:
93
+ only: /.*/
94
+ branches:
95
+ ignore: /.*/
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # manually added
2
+ test_results/
3
+ danger-*.gem
4
+
5
+ .DS_Store
6
+ pkg
7
+ .idea/
8
+ .yardoc
data/.rubocop.yml ADDED
@@ -0,0 +1,152 @@
1
+ # Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
2
+
3
+ # If you don't like these settings, just delete this file :)
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.1
7
+
8
+ Style/StringLiterals:
9
+ EnforcedStyle: double_quotes
10
+ Enabled: true
11
+
12
+ # kind_of? is a good way to check a type
13
+ Style/ClassCheck:
14
+ EnforcedStyle: kind_of?
15
+
16
+ # It's better to be more explicit about the type
17
+ Style/BracesAroundHashParameters:
18
+ Enabled: false
19
+
20
+ # specs sometimes have useless assignments, which is fine
21
+ Lint/UselessAssignment:
22
+ Exclude:
23
+ - '**/spec/**/*'
24
+
25
+ # We could potentially enable the 2 below:
26
+ Layout/IndentHash:
27
+ Enabled: false
28
+
29
+ Layout/AlignHash:
30
+ Enabled: false
31
+
32
+ # HoundCI doesn't like this rule
33
+ Layout/DotPosition:
34
+ Enabled: false
35
+
36
+ # We allow !! as it's an easy way to convert ot boolean
37
+ Style/DoubleNegation:
38
+ Enabled: false
39
+
40
+ # Cop supports --auto-correct.
41
+ Lint/UnusedBlockArgument:
42
+ Enabled: false
43
+
44
+ # We want to allow class Fastlane::Class
45
+ Style/ClassAndModuleChildren:
46
+ Enabled: false
47
+
48
+ Metrics/AbcSize:
49
+ Max: 60
50
+
51
+ # The %w might be confusing for new users
52
+ Style/WordArray:
53
+ MinSize: 19
54
+
55
+ # raise and fail are both okay
56
+ Style/SignalException:
57
+ Enabled: false
58
+
59
+ # Better too much 'return' than one missing
60
+ Style/RedundantReturn:
61
+ Enabled: false
62
+
63
+ # Having if in the same line might not always be good
64
+ Style/IfUnlessModifier:
65
+ Enabled: false
66
+
67
+ # and and or is okay
68
+ Style/AndOr:
69
+ Enabled: false
70
+
71
+ # Configuration parameters: CountComments.
72
+ Metrics/ClassLength:
73
+ Max: 350
74
+
75
+ Metrics/CyclomaticComplexity:
76
+ Max: 17
77
+
78
+ # Configuration parameters: AllowURI, URISchemes.
79
+ Metrics/LineLength:
80
+ Max: 370
81
+
82
+ # Configuration parameters: CountKeywordArgs.
83
+ Metrics/ParameterLists:
84
+ Max: 10
85
+
86
+ Metrics/PerceivedComplexity:
87
+ Max: 18
88
+
89
+ # Sometimes it's easier to read without guards
90
+ Style/GuardClause:
91
+ Enabled: false
92
+
93
+ # something = if something_else
94
+ # that's confusing
95
+ Style/ConditionalAssignment:
96
+ Enabled: false
97
+
98
+ # Better to have too much self than missing a self
99
+ Style/RedundantSelf:
100
+ Enabled: false
101
+
102
+ Metrics/MethodLength:
103
+ Max: 60
104
+
105
+ # We're not there yet
106
+ Style/Documentation:
107
+ Enabled: false
108
+
109
+ # Adds complexity
110
+ Style/IfInsideElse:
111
+ Enabled: false
112
+
113
+ # danger specific
114
+
115
+ Style/BlockComments:
116
+ Enabled: false
117
+
118
+ Layout/MultilineMethodCallIndentation:
119
+ EnforcedStyle: indented
120
+
121
+ # FIXME: 25
122
+ Metrics/BlockLength:
123
+ Max: 345
124
+ Exclude:
125
+ - "**/*_spec.rb"
126
+
127
+ Style/MixinGrouping:
128
+ Enabled: false
129
+
130
+ Style/FileName:
131
+ Enabled: false
132
+
133
+ Layout/IndentHeredoc:
134
+ Enabled: false
135
+
136
+ Style/SpecialGlobalVars:
137
+ Enabled: false
138
+
139
+ PercentLiteralDelimiters:
140
+ PreferredDelimiters:
141
+ "%": ()
142
+ "%i": ()
143
+ "%q": ()
144
+ "%Q": ()
145
+ "%r": "{}"
146
+ "%s": ()
147
+ "%w": ()
148
+ "%W": ()
149
+ "%x": ()
150
+
151
+ Security/YAMLLoad:
152
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ cache:
3
+ directories:
4
+ - bundle
5
+
6
+ rvm:
7
+ - 2.0
8
+ - 2.1.3
9
+ - 2.3.1
10
+
11
+ script:
12
+ - bundle exec rake spec
data/Dangerfile ADDED
@@ -0,0 +1,6 @@
1
+ if github.branch_for_base == "master"
2
+ diff = git.diff_for_file("lib/android_version_change/gem_version.rb")
3
+ if !diff
4
+ fail 'You did not update the gem version.'
5
+ end
6
+ end
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-ios_version_change.gemspec
4
+ gemspec
5
+
6
+ # Added at 2017-12-04 17:20:03 -0600 by levibostian:
7
+ gem "rspec_junit_formatter", "~> 0.3.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,138 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danger-android_version_change (0.1.0)
5
+ danger-plugin-api (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.5.2)
11
+ public_suffix (>= 2.0.2, < 4.0)
12
+ ast (2.3.0)
13
+ claide (1.0.2)
14
+ claide-plugins (0.9.2)
15
+ cork
16
+ nap
17
+ open4 (~> 1.3)
18
+ coderay (1.1.2)
19
+ colored2 (3.1.2)
20
+ cork (0.3.0)
21
+ colored2 (~> 3.1)
22
+ danger (5.5.5)
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
+ no_proxy_fix
32
+ octokit (~> 4.7)
33
+ terminal-table (~> 1)
34
+ danger-plugin-api (1.0.0)
35
+ danger (> 2.0)
36
+ diff-lcs (1.3)
37
+ faraday (0.13.1)
38
+ multipart-post (>= 1.2, < 3)
39
+ faraday-http-cache (1.3.1)
40
+ faraday (~> 0.8)
41
+ ffi (1.9.18)
42
+ formatador (0.2.5)
43
+ git (1.3.0)
44
+ guard (2.14.1)
45
+ formatador (>= 0.2.4)
46
+ listen (>= 2.7, < 4.0)
47
+ lumberjack (~> 1.0)
48
+ nenv (~> 0.1)
49
+ notiffany (~> 0.0)
50
+ pry (>= 0.9.12)
51
+ shellany (~> 0.0)
52
+ thor (>= 0.18.1)
53
+ guard-compat (1.2.1)
54
+ guard-rspec (4.7.3)
55
+ guard (~> 2.1)
56
+ guard-compat (~> 1.1)
57
+ rspec (>= 2.99.0, < 4.0)
58
+ kramdown (1.16.2)
59
+ listen (3.0.7)
60
+ rb-fsevent (>= 0.9.3)
61
+ rb-inotify (>= 0.9.7)
62
+ lumberjack (1.0.12)
63
+ method_source (0.9.0)
64
+ multipart-post (2.0.0)
65
+ nap (1.1.0)
66
+ nenv (0.3.0)
67
+ no_proxy_fix (0.1.2)
68
+ notiffany (0.1.1)
69
+ nenv (~> 0.1)
70
+ shellany (~> 0.0)
71
+ octokit (4.7.0)
72
+ sawyer (~> 0.8.0, >= 0.5.3)
73
+ open4 (1.3.4)
74
+ parallel (1.12.0)
75
+ parser (2.4.0.2)
76
+ ast (~> 2.3)
77
+ powerpack (0.1.1)
78
+ pry (0.11.3)
79
+ coderay (~> 1.1.0)
80
+ method_source (~> 0.9.0)
81
+ public_suffix (3.0.1)
82
+ rainbow (2.2.2)
83
+ rake
84
+ rake (10.5.0)
85
+ rb-fsevent (0.10.2)
86
+ rb-inotify (0.9.10)
87
+ ffi (>= 0.5.0, < 2)
88
+ rspec (3.7.0)
89
+ rspec-core (~> 3.7.0)
90
+ rspec-expectations (~> 3.7.0)
91
+ rspec-mocks (~> 3.7.0)
92
+ rspec-core (3.7.0)
93
+ rspec-support (~> 3.7.0)
94
+ rspec-expectations (3.7.0)
95
+ diff-lcs (>= 1.2.0, < 2.0)
96
+ rspec-support (~> 3.7.0)
97
+ rspec-mocks (3.7.0)
98
+ diff-lcs (>= 1.2.0, < 2.0)
99
+ rspec-support (~> 3.7.0)
100
+ rspec-support (3.7.0)
101
+ rspec_junit_formatter (0.3.0)
102
+ rspec-core (>= 2, < 4, != 2.12.0)
103
+ rubocop (0.51.0)
104
+ parallel (~> 1.10)
105
+ parser (>= 2.3.3.1, < 3.0)
106
+ powerpack (~> 0.1)
107
+ rainbow (>= 2.2.2, < 3.0)
108
+ ruby-progressbar (~> 1.7)
109
+ unicode-display_width (~> 1.0, >= 1.0.1)
110
+ ruby-progressbar (1.9.0)
111
+ sawyer (0.8.1)
112
+ addressable (>= 2.3.5, < 2.6)
113
+ faraday (~> 0.8, < 1.0)
114
+ shellany (0.0.1)
115
+ terminal-table (1.8.0)
116
+ unicode-display_width (~> 1.1, >= 1.1.1)
117
+ thor (0.20.0)
118
+ unicode-display_width (1.3.0)
119
+ yard (0.9.12)
120
+
121
+ PLATFORMS
122
+ ruby
123
+
124
+ DEPENDENCIES
125
+ bundler (~> 1.3)
126
+ danger-android_version_change!
127
+ guard (~> 2.14)
128
+ guard-rspec (~> 4.7)
129
+ listen (= 3.0.7)
130
+ pry
131
+ rake (~> 10.0)
132
+ rspec (~> 3.4)
133
+ rspec_junit_formatter (~> 0.3.0)
134
+ rubocop (~> 0.49)
135
+ yard (~> 0.8)
136
+
137
+ BUNDLED WITH
138
+ 1.16.0
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 Levi Bostian <levi.bostian@gmail.com>
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.
@@ -0,0 +1,3 @@
1
+ - [ ] Update `lib/android_version_change/gem_version.rb` to latest version. Bump it!
2
+ - [ ] Tests all pass.
3
+ - [ ] After merge, make a git tag release.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ ![https://circleci.com/gh/levibostian/danger-android_version_change/tree/master.png](https://circleci.com/gh/levibostian/danger-android_version_change/tree/master.png)
2
+
3
+
4
+ ### android_version_change
5
+
6
+ Asserts the versionName or versionCode strings have been changed in your Android project.
7
+ This is done by checking the git diff of your project's build.gradle file.
8
+ The plugin will either call Danger's fail method or do nothing if the versionName or versionCode strings were changed.
9
+
10
+ android_version_change.assert_version_name_changed()
11
+
12
+ # Calls Danger `fail` if the versionName not updated or nothing if it has changed.
13
+ android_version_change.assert_version_code_changed()
14
+
15
+ <blockquote>Assert the versionName string changed for your Android project
16
+ <pre># Calls Danger `fail` if the versionName not updated or nothing if it has changed.</pre>
17
+ </blockquote>
18
+
19
+
20
+
21
+
22
+
23
+ #### Methods
24
+
25
+ `assert_version_changed_diff` - (Internal use) Pass the git diff string here to see if the version string has been updated.
26
+
27
+ `assert_version_changed` - (Internal use) Takes path to build.gradle as well as "versionName" or "versionCode" string to check for change.
28
+
29
+ `assert_version_name_changed` - Assert the versionName has been changed in your build.gradle file.
30
+
31
+ android_version_change.assert_version_name_changed()
32
+
33
+ # If your build.gradle file is not located in the default location: `app/build.gradle`
34
+ android_version_change.assert_version_name_changed("specialDirectory/build.gradle")
35
+
36
+ `assert_version_code_changed` - Assert the versionCode has been changed in your build.gradle file.
37
+
38
+ android_version_change.assert_version_code_changed()
39
+
40
+ # If your build.gradle file is not located in the default location: `app/build.gradle`
41
+ android_version_change.assert_version_code_changed("specialDirectory/build.gradle")
42
+
43
+
44
+
45
+
46
+ ### Development
47
+
48
+ 1. Clone this repo
49
+ 2. Run `bundle install` to setup dependencies.
50
+ 3. Run `bundle exec rake spec` to run the tests.
51
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
52
+ 5. Make your changes.
data/README_footer.md ADDED
@@ -0,0 +1,7 @@
1
+ ### Development
2
+
3
+ 1. Clone this repo
4
+ 2. Run `bundle install` to setup dependencies.
5
+ 3. Run `bundle exec rake spec` to run the tests.
6
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
7
+ 5. Make your changes.
data/README_header.md ADDED
@@ -0,0 +1 @@
1
+ ![https://circleci.com/gh/levibostian/danger-android_version_change/tree/master.png](https://circleci.com/gh/levibostian/danger-android_version_change/tree/master.png)
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
@@ -0,0 +1,4 @@
1
+ if [[ -z "${CI_PULL_REQUESTS}" ]]; then
2
+ echo -e "\033[31merror: Danger requires a pull request to function correctly\033[0m"
3
+ exit 1
4
+ fi
@@ -0,0 +1,51 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'android_version_change/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'danger-android_version_change'
8
+ spec.version = AndroidVersionChange::VERSION
9
+ spec.authors = ['Levi Bostian']
10
+ spec.email = ['levi.bostian@gmail.com']
11
+ spec.description = "Asserts the versionName or versionCode strings have been changed in your Android project."
12
+ spec.summary = "Asserts the versionName or versionCode strings have been changed in your Android project. Fails using Danger when the Android versionName or versionCode strings have not been updated and does nothing if either have. Uses git diff on build.gradle file to check if versionName or versinCode have been updated."
13
+ spec.homepage = 'https://github.com/levibostian/danger-android_version_change'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ # spec.add_runtime_dependency 'git'
22
+
23
+ spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
24
+
25
+ # General ruby development
26
+ spec.add_development_dependency 'bundler', '~> 1.3'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+
29
+ # Testing support
30
+ spec.add_development_dependency 'rspec', '~> 3.4'
31
+
32
+ # Linting code and docs
33
+ spec.add_development_dependency "rubocop", "~> 0.49"
34
+ spec.add_development_dependency "yard", "~> 0.8"
35
+
36
+ # Makes testing easy via `bundle exec guard`
37
+ spec.add_development_dependency 'guard', '~> 2.14'
38
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
39
+
40
+ # If you want to work on older builds of ruby
41
+ spec.add_development_dependency 'listen', '3.0.7'
42
+
43
+ # This gives you the chance to run a REPL inside your tests
44
+ # via:
45
+ #
46
+ # require 'pry'
47
+ # binding.pry
48
+ #
49
+ # This will stop test execution and let you inspect the results
50
+ spec.add_development_dependency 'pry'
51
+ end
@@ -0,0 +1,3 @@
1
+ module AndroidVersionChange
2
+ VERSION = "0.1.0".freeze
3
+ end
@@ -0,0 +1,93 @@
1
+
2
+ module Danger
3
+ # Asserts the versionName or versionCode strings have been changed in your Android project.
4
+ # This is done by checking the git diff of your project's build.gradle file.
5
+ # The plugin will either call Danger's fail method or do nothing if the versionName or versionCode strings were changed.
6
+ #
7
+ # @example Assert the versionName string changed for your Android project
8
+ # # Calls Danger `fail` if the versionName not updated or nothing if it has changed.
9
+ # android_version_change.assert_version_name_changed()
10
+ #
11
+ # # Calls Danger `fail` if the versionName not updated or nothing if it has changed.
12
+ # android_version_change.assert_version_code_changed()
13
+ #
14
+ # @tags android, ci, continuous integration, android version, danger, dangerfile, danger plugin
15
+ class DangerAndroidVersionChange < Plugin
16
+ # The instance name used in the Dangerfile
17
+ # @return [String]
18
+ #
19
+ def self.instance_name
20
+ "android_version_change"
21
+ end
22
+
23
+ def initialize(dangerfile)
24
+ super(dangerfile)
25
+ end
26
+
27
+ # (Internal use) Pass the git diff string here to see if the version string has been updated.
28
+ # @return [void]
29
+ def assert_version_changed_diff(git_diff_string, name_or_code)
30
+ git_diff_lines = git_diff_string.lines
31
+ git_diff_string.each_line.each_with_index do |line, index|
32
+ next unless line.include? name_or_code
33
+ # we need to check the current line and the next line of the string to determine if it's a git diff change.
34
+ if git_diff_lines.length >= (index + 2) && git_diff_lines[index][0] == "-" && git_diff_lines[index + 1][0] == "+"
35
+ return # rubocop:disable NonLocalExitFromIterator
36
+ end
37
+ end
38
+
39
+ fail "You did not change the Android " + name_or_code + "."
40
+ end
41
+
42
+ # (Internal use) Takes path to build.gradle as well as "versionName" or "versionCode" string to check for change.
43
+ # @return [void]
44
+ def assert_version_changed(override_build_gradle_file_path, name_or_code)
45
+ build_gradle_file_path = override_build_gradle_file_path || "app/build.gradle"
46
+
47
+ unless File.file?(build_gradle_file_path)
48
+ fail "build.gradle file at path " + build_gradle_file_path + " does not exist."
49
+ return # rubocop:disable UnreachableCode
50
+ end
51
+
52
+ unless git.diff_for_file(build_gradle_file_path) # No diff found for build.gradle file.
53
+ fail "You did not edit your build.gradle file at all. Therefore, you did not change the " + name_or_code + "."
54
+ return # rubocop:disable UnreachableCode
55
+ end
56
+
57
+ git_diff_string = git.diff_for_file(info_plist_file_path).patch
58
+ assert_version_changed_diff(git_diff_string, name_or_code)
59
+ end
60
+
61
+ # Assert the versionName has been changed in your build.gradle file.
62
+ #
63
+ # @example Assert the versionName has been changed in your Android project.
64
+ # # Calls Danger `fail` if the versionName not updated or nothing if it has changed.
65
+ # android_version_change.assert_version_name_changed()
66
+ #
67
+ # # If your build.gradle file is not located in the default location: `app/build.gradle`
68
+ # android_version_change.assert_version_name_changed("specialDirectory/build.gradle")
69
+ #
70
+ # @param [String] override_build_gradle_file_path
71
+ # (optional) Path to build.gradle file for Android project that versionName is located in.
72
+ # @return [void]
73
+ def assert_version_name_changed(override_build_gradle_file_path)
74
+ assert_version_changed(override_build_gradle_file_path, "versionName")
75
+ end
76
+
77
+ # Assert the versionCode has been changed in your build.gradle file.
78
+ #
79
+ # @example Assert the versionCode has been changed in your Android project.
80
+ # # Calls Danger `fail` if the versionName not updated or nothing if it has changed.
81
+ # android_version_change.assert_version_code_changed()
82
+ #
83
+ # # If your build.gradle file is not located in the default location: `app/build.gradle`
84
+ # android_version_change.assert_version_code_changed("specialDirectory/build.gradle")
85
+ #
86
+ # @param [String] override_build_gradle_file_path
87
+ # (optional) Path to build.gradle file for Android project that versionCode is located in.
88
+ # @return [void]
89
+ def assert_version_code_changed(override_build_gradle_file_path)
90
+ assert_version_changed(override_build_gradle_file_path, "versionCode")
91
+ end
92
+ end
93
+ end
@@ -0,0 +1 @@
1
+ require "android_version_change/gem_version"
@@ -0,0 +1 @@
1
+ require "android_version_change/plugin"
@@ -0,0 +1,15 @@
1
+ diff --git a/Foo/app/build.gradle b/Foo/app/build.gradle
2
+ index de56abf..994a384 100644
3
+ --- a/Foo/app/build.gradle
4
+ +++ b/Foo/app/build.gradle
5
+ @@ -15,18 +15,18 @@
6
+ apply plugin: 'com.android.application'
7
+
8
+ repositories {
9
+ maven { url 'https://maven.google.com' }
10
+ }
11
+
12
+ android {
13
+ defaultConfig {
14
+ - versionCode whateverDoesntMatter
15
+ + versionCode whateverDoesntMatter
@@ -0,0 +1,15 @@
1
+ diff --git a/Foo/app/build.gradle b/Foo/app/build.gradle
2
+ index de56abf..994a384 100644
3
+ --- a/Foo/app/build.gradle
4
+ +++ b/Foo/app/build.gradle
5
+ @@ -15,18 +15,18 @@
6
+ apply plugin: 'com.android.application'
7
+
8
+ repositories {
9
+ maven { url 'https://maven.google.com' }
10
+ }
11
+
12
+ android {
13
+ defaultConfig {
14
+ - versionName whateverDoesntMatter
15
+ + versionName whateverDoesntMatter
@@ -0,0 +1,16 @@
1
+ diff --git a/Foo/app/build.gradle b/Foo/app/build.gradle
2
+ index de56abf..994a384 100644
3
+ --- a/Foo/app/build.gradle
4
+ +++ b/Foo/app/build.gradle
5
+ @@ -15,18 +15,18 @@
6
+ apply plugin: 'com.android.application'
7
+
8
+ repositories {
9
+ maven { url 'https://maven.google.com' }
10
+ }
11
+
12
+ android {
13
+ defaultConfig {
14
+ versionCode whateverDoesntMatter
15
+ - versionName whateverDoesntMatter
16
+ + versionName whateverDoesntMatter
@@ -0,0 +1,16 @@
1
+ diff --git a/Foo/app/build.gradle b/Foo/app/build.gradle
2
+ index de56abf..994a384 100644
3
+ --- a/Foo/app/build.gradle
4
+ +++ b/Foo/app/build.gradle
5
+ @@ -15,18 +15,18 @@
6
+ apply plugin: 'com.android.application'
7
+
8
+ repositories {
9
+ maven { url 'https://maven.google.com' }
10
+ }
11
+
12
+ android {
13
+ defaultConfig {
14
+ versionName whateverDoesntMatter
15
+ - versionCode whateverDoesntMatter
16
+ + versionCode whateverDoesntMatter
@@ -0,0 +1,14 @@
1
+ diff --git a/Foo/app/build.gradle b/Foo/app/build.gradle
2
+ index de56abf..994a384 100644
3
+ --- a/Foo/app/build.gradle
4
+ +++ b/Foo/app/build.gradle
5
+ @@ -15,18 +15,18 @@
6
+ apply plugin: 'com.android.application'
7
+
8
+ repositories {
9
+ maven { url 'https://maven.google.com' }
10
+ }
11
+
12
+ android {
13
+ defaultConfig {
14
+ - versionCode whateverDoesntMatter
@@ -0,0 +1,58 @@
1
+ require File.expand_path("../spec_helper", __FILE__)
2
+
3
+ module Danger
4
+ describe Danger::DangerAndroidVersionChange do
5
+ #
6
+ # You should test your custom attributes and methods here
7
+ #
8
+ describe "with Dangerfile" do
9
+ before do
10
+ @dangerfile = testing_dangerfile
11
+ @my_plugin = @dangerfile.android_version_change
12
+ end
13
+
14
+ # Some examples for writing tests
15
+ # You should replace these with your own.
16
+
17
+ it "Cannot find build.gradle file" do
18
+ @my_plugin.assert_version_changed("Foo/Bar/build.gradle", "versionName")
19
+ expect(@dangerfile.status_report[:errors]).to eq(["build.gradle file at path Foo/Bar/build.gradle does not exist."])
20
+ end
21
+
22
+ it "Fails from an empty git diff message" do
23
+ @my_plugin.assert_version_changed_diff("", "versionName")
24
+ expect(@dangerfile.status_report[:errors]).to eq(["You did not change the Android versionName."])
25
+ end
26
+
27
+ it "Successfully detects versionName changed" do
28
+ diff = File.read("spec/ChangedVersionNameGitDiff.txt")
29
+ @my_plugin.assert_version_changed_diff(diff, "versionName")
30
+ expect(@dangerfile.status_report[:errors]).to eq([])
31
+ end
32
+
33
+ it "Successfully detects versionCode changed" do
34
+ diff = File.read("spec/ChangedVersionCodeGitDiff.txt")
35
+ @my_plugin.assert_version_changed_diff(diff, "versionCode")
36
+ expect(@dangerfile.status_report[:errors]).to eq([])
37
+ end
38
+
39
+ it "Runs into end of git diff. This should never happen, but I need to test the built in error handling." do
40
+ diff = File.read("spec/RunIntoEndOfFileGitDiff.txt")
41
+ @my_plugin.assert_version_changed_diff(diff, "versionName")
42
+ expect(@dangerfile.status_report[:errors]).to eq(["You did not change the Android versionName."])
43
+ end
44
+
45
+ it "versionName was not changed." do
46
+ diff = File.read("spec/NotChangedVersionNameGitDiff.txt")
47
+ @my_plugin.assert_version_changed_diff(diff, "versionName")
48
+ expect(@dangerfile.status_report[:errors]).to eq(["You did not change the Android versionName."])
49
+ end
50
+
51
+ it "versionCode was not changed." do
52
+ diff = File.read("spec/NotChangedVersionCodeGitDiff.txt")
53
+ @my_plugin.assert_version_changed_diff(diff, "versionCode")
54
+ expect(@dangerfile.status_report[:errors]).to eq(["You did not change the Android versionCode."])
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,65 @@
1
+ require "pathname"
2
+ ROOT = Pathname.new(File.expand_path("../../", __FILE__))
3
+ $:.unshift((ROOT + "lib").to_s)
4
+ $:.unshift((ROOT + "spec").to_s)
5
+
6
+ require "bundler/setup"
7
+ require "pry"
8
+
9
+ require "rspec"
10
+ require "danger"
11
+
12
+ if `git remote -v` == ""
13
+ puts "You cannot run tests without setting a local git remote on this repo"
14
+ puts "It's a weird side-effect of Danger's internals."
15
+ exit(0)
16
+ end
17
+
18
+ # Use coloured output, it's the best.
19
+ RSpec.configure do |config|
20
+ config.filter_gems_from_backtrace "bundler"
21
+ config.color = true
22
+ config.tty = true
23
+ end
24
+
25
+ require "danger_plugin"
26
+
27
+ # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
28
+ # If you are expanding these files, see if it's already been done ^.
29
+
30
+ # A silent version of the user interface,
31
+ # it comes with an extra function `.string` which will
32
+ # strip all ANSI colours from the string.
33
+
34
+ # rubocop:disable Lint/NestedMethodDefinition
35
+ def testing_ui
36
+ @output = StringIO.new
37
+ def @output.winsize
38
+ [20, 9999]
39
+ end
40
+
41
+ cork = Cork::Board.new(out: @output)
42
+ def cork.string
43
+ out.string.gsub(/\e\[([;\d]+)?m/, "")
44
+ end
45
+ cork
46
+ end
47
+ # rubocop:enable Lint/NestedMethodDefinition
48
+
49
+ # Example environment (ENV) that would come from
50
+ # running a PR on TravisCI
51
+ def testing_env
52
+ {
53
+ "HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
54
+ "TRAVIS_PULL_REQUEST" => "800",
55
+ "TRAVIS_REPO_SLUG" => "artsy/eigen",
56
+ "TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
57
+ "DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
58
+ }
59
+ end
60
+
61
+ # A stubbed out Dangerfile for use in tests
62
+ def testing_dangerfile
63
+ env = Danger::EnvironmentManager.new(testing_env)
64
+ Danger::Dangerfile.new(env, testing_ui)
65
+ end
metadata ADDED
@@ -0,0 +1,222 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-android_version_change
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Levi Bostian
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: danger-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
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.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
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.49'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.49'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.14'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '4.7'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '4.7'
125
+ - !ruby/object:Gem::Dependency
126
+ name: listen
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 3.0.7
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 3.0.7
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Asserts the versionName or versionCode strings have been changed in your
154
+ Android project.
155
+ email:
156
+ - levi.bostian@gmail.com
157
+ executables: []
158
+ extensions: []
159
+ extra_rdoc_files: []
160
+ files:
161
+ - ".circleci/config.yml"
162
+ - ".gitignore"
163
+ - ".rubocop.yml"
164
+ - ".travis.yml"
165
+ - Dangerfile
166
+ - Gemfile
167
+ - Gemfile.lock
168
+ - Guardfile
169
+ - LICENSE.txt
170
+ - PULL_REQUEST_TEMPLATE.md
171
+ - README.md
172
+ - README_footer.md
173
+ - README_header.md
174
+ - Rakefile
175
+ - assert_danger_running_on_pr.sh
176
+ - danger-android_version_change.gemspec
177
+ - lib/android_version_change/gem_version.rb
178
+ - lib/android_version_change/plugin.rb
179
+ - lib/danger_android_version_change.rb
180
+ - lib/danger_plugin.rb
181
+ - spec/ChangedVersionCodeGitDiff.txt
182
+ - spec/ChangedVersionNameGitDiff.txt
183
+ - spec/NotChangedVersionCodeGitDiff.txt
184
+ - spec/NotChangedVersionNameGitDiff.txt
185
+ - spec/RunIntoEndOfFileGitDiff.txt
186
+ - spec/android_version_change_spec.rb
187
+ - spec/spec_helper.rb
188
+ homepage: https://github.com/levibostian/danger-android_version_change
189
+ licenses:
190
+ - MIT
191
+ metadata: {}
192
+ post_install_message:
193
+ rdoc_options: []
194
+ require_paths:
195
+ - lib
196
+ required_ruby_version: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '0'
201
+ required_rubygems_version: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ requirements: []
207
+ rubyforge_project:
208
+ rubygems_version: 2.7.3
209
+ signing_key:
210
+ specification_version: 4
211
+ summary: Asserts the versionName or versionCode strings have been changed in your
212
+ Android project. Fails using Danger when the Android versionName or versionCode
213
+ strings have not been updated and does nothing if either have. Uses git diff on
214
+ build.gradle file to check if versionName or versinCode have been updated.
215
+ test_files:
216
+ - spec/ChangedVersionCodeGitDiff.txt
217
+ - spec/ChangedVersionNameGitDiff.txt
218
+ - spec/NotChangedVersionCodeGitDiff.txt
219
+ - spec/NotChangedVersionNameGitDiff.txt
220
+ - spec/RunIntoEndOfFileGitDiff.txt
221
+ - spec/android_version_change_spec.rb
222
+ - spec/spec_helper.rb