Created
June 4, 2016 19:55
-
-
Save thecb4/005f0deb4f9d959410b24b25a7beb01b to your computer and use it in GitHub Desktop.
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
module Fastlane | |
module Actions | |
module SharedValues | |
GIT_DOCUMENTED_COMMIT_CUSTOM_VALUE = :GIT_DOCUMENTED_COMMIT_CUSTOM_VALUE | |
end | |
# To share this integration with the other fastlane users: | |
# - Fork https://github.com/fastlane/fastlane/tree/master/fastlane | |
# - Clone the forked repository | |
# - Move this integration into lib/fastlane/actions | |
# - Commit, push and submit the pull request | |
class GitDocumentedCommitAction < Action | |
def self.run(params) | |
# fastlane will take care of reading in the parameter and fetching the environment variable: | |
UI.message "Commit Message Source: #{params[:commit_message]}" | |
UI.message "Changelog Source: #{params[:change_log]}" | |
# sh "shellcommand ./path" | |
# Actions.lane_context[SharedValues::GIT_DOCUMENTED_COMMIT_CUSTOM_VALUE] = "my_val" | |
commitMessage = Actions.sh("cat #{params[:commit_message]}") | |
puts "✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️" | |
puts "#{commitMessage}" | |
puts "✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️ ✈️" | |
modifiedCommitMsg = Actions.sh("git diff --name-only #{params[:commit_message]}") | |
UI.user_error!("🚨 Commit message has not been modified since last git commit") unless (modifiedCommitMsg and not modifiedCommitMsg.empty?) | |
modifiedChangeLog = Actions.sh("git diff --name-only #{params[:change_log]}") | |
UI.user_error!("🚨 Commit message has not been modified since last git commit") unless (modifiedChangeLog and not modifiedChangeLog.empty?) | |
Actions.sh("git add .") | |
Actions.sh("git commit -F #{params[:commit_message]}") | |
end | |
##################################################### | |
# @!group Documentation | |
##################################################### | |
def self.description | |
"A short description with <= 80 characters of what this action does" | |
end | |
def self.details | |
# Optional: | |
# this is your chance to provide a more detailed description of this action | |
"You can use this action to do cool things..." | |
end | |
def self.available_options | |
# Define all options your action supports. | |
# Below a few examples | |
[ | |
FastlaneCore::ConfigItem.new(key: :commit_message, | |
env_name: "FL_GIT_DOCUMENTED_COMMIT_COMMIT_MESSAGE", # The name of the environment variable | |
description: "Commit Message for GitDocumentedCommitAction", # a short description of this parameter | |
verify_block: proc do |value| | |
UI.user_error!("Commit Message for GitDocumentedCommitAction given, pass using `commit_message: 'message.md'`") unless (value and not value.empty?) | |
UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value) | |
end, | |
default_value: "COMMIT_MSG.md"), # the default value if the user didn't provide one | |
FastlaneCore::ConfigItem.new(key: :change_log, | |
env_name: "FL_GIT_DOCUMENTED_COMMIT_CHANGELOG", | |
description: "Path to Change Log", | |
verify_block: proc do |value| | |
UI.user_error!("Change Log for GitDocumentedCommitAction given, pass using `change_log: 'changelog.md'`") unless (value and not value.empty?) | |
UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value) | |
end, | |
default_value: "CHANGELOG.md") # the default value if the user didn't provide one | |
] | |
end | |
def self.output | |
# Define the shared values you are going to provide | |
# Example | |
[ | |
#['GIT_DOCUMENTED_COMMIT_CUSTOM_VALUE', 'A description of what this value contains'] | |
] | |
end | |
def self.return_value | |
# If you method provides a return value, you can describe here what it does | |
end | |
def self.authors | |
# So no one will ever forget your contribution to fastlane :) You are awesome btw! | |
["theCB4"] | |
end | |
def self.is_supported?(platform) | |
# you can do things like | |
# | |
# true | |
# | |
# platform == :ios | |
# | |
# [:ios, :mac].include?(platform) | |
# | |
platform == :ios | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment