forked from f100024/fastlane-plugin-bitbucket
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from natura-cosmeticos/STEM-3008-compare-commits
STEM-3008: Create actions to search keywords and locked files
- Loading branch information
Showing
3 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
lib/fastlane/plugin/bitbucket/actions/is_diffstat_changing_locked_files_action.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
module Fastlane | ||
module Actions | ||
class IsDiffstatChangingLockedFilesAction < Action | ||
|
||
def self.run(params) | ||
diffstat = params[:diffstat] | ||
file_name_prefix = params[:file_name_prefix] | ||
|
||
locked_files = params[:locked_files].split(/,/) | ||
edited_locked_files = false | ||
|
||
diffstat.each_line do |line| | ||
if !line.start_with? file_name_prefix | ||
next | ||
end | ||
|
||
file_name = line.delete_prefix("#{file_name_prefix} b/").delete_suffix("\n") | ||
if locked_files.any? { |file| file_name.match? file } | ||
return true | ||
end | ||
end | ||
|
||
false | ||
end | ||
|
||
def self.description | ||
"This action returns if a diffstat is changing a forbidden file." | ||
end | ||
|
||
def self.authors | ||
["Igor Matos, Daniel Nazareth"] | ||
end | ||
|
||
def self.available_options | ||
[ | ||
FastlaneCore::ConfigItem.new( | ||
key: :diffstat, | ||
description: "The diffstat between two commits", | ||
optional: false, | ||
type: String, | ||
), | ||
FastlaneCore::ConfigItem.new( | ||
key: :file_name_prefix, | ||
description: "The prefix keyword that identifies a file name. eg: +++", | ||
optional: false, | ||
type: String, | ||
), | ||
FastlaneCore::ConfigItem.new( | ||
key: :locked_files, | ||
description: "Files that should not be changed, with extension. eg: myfile.xml", | ||
type: String, | ||
optional: false, | ||
) | ||
] | ||
end | ||
|
||
def self.is_supported?(platform) | ||
true | ||
end | ||
end | ||
end | ||
end |
43 changes: 43 additions & 0 deletions
43
lib/fastlane/plugin/bitbucket/actions/string_contains_keywords_action.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module Fastlane | ||
module Actions | ||
class StringContainsKeywordsAction < Action | ||
|
||
def self.run(params) | ||
text = params[:text] | ||
keywords = params[:keywords].split(/,/) | ||
has_keyword = keywords.any? { |keyword| text.include?(keyword) } | ||
|
||
has_keyword | ||
end | ||
|
||
def self.description | ||
"This action returns if a string contains any of the defined keywords." | ||
end | ||
|
||
def self.authors | ||
["Igor Matos, Daniel Nazareth"] | ||
end | ||
|
||
def self.available_options | ||
[ | ||
FastlaneCore::ConfigItem.new( | ||
key: :text, | ||
description: "The base text that will look for keywords on each line", | ||
optional: false, | ||
type: String, | ||
), | ||
FastlaneCore::ConfigItem.new( | ||
key: :keywords, | ||
description: "Keywords to be looked for. eg: @Supress", | ||
type: String, | ||
optional: false, | ||
) | ||
] | ||
end | ||
|
||
def self.is_supported?(platform) | ||
true | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Fastlane | ||
module Bitbucket | ||
VERSION = "0.1.22" | ||
VERSION = "0.1.23" | ||
end | ||
end |