Skip to content

Commit

Permalink
Merge pull request #15 from natura-cosmeticos/STEM-3008-compare-commits
Browse files Browse the repository at this point in the history
STEM-3008: Create actions to search keywords and locked files
  • Loading branch information
dbnaza authored Jun 2, 2022
2 parents f75f9d6 + e118d36 commit 9a6f53b
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 1 deletion.
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
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
2 changes: 1 addition & 1 deletion lib/fastlane/plugin/bitbucket/version.rb
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

0 comments on commit 9a6f53b

Please sign in to comment.