Skip to content

Instantly share code, notes, and snippets.

@megimix
Created February 21, 2017 17:04
Show Gist options
  • Save megimix/1b64ba77ff8d90e582cbe9751b4e9ca2 to your computer and use it in GitHub Desktop.
Save megimix/1b64ba77ff8d90e582cbe9751b4e9ca2 to your computer and use it in GitHub Desktop.
Fastlane Action for resetting git branch to remote
module Fastlane
module Actions
module SharedValues
GIT_CHECKOUT_BRANCH_AND_RESET = :GIT_CHECKOUT_BRANCH_AND_RESET
end
class GitCheckoutResetHardAction < Action
def self.run(params)
remote_branch = params[:remote_branch]
Actions.sh("git fetch")
Actions.sh("git checkout #{remote_branch}")
Actions.sh("git reset --hard origin/#{remote_branch}")
end
#####################################################
# @!group Documentation
#####################################################
def self.description
'Checkout a branch from project working copy and reset hard to origin'
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :remote_branch,
env_name: "GIT_CHECKOUT_BRANCH_AND_RESET",
description: "The branch name that needs to be checkout and reset to origin",
is_string: true,
default_value: "develop")
]
end
def self.output
[
['GIT_CHECKOUT_BRANCH_AND_RESET', 'The branch name that needs to be checkout and reset to origin']
]
end
def self.authors
["Megimix inspired by fabiomilano"]
end
def self.is_supported?(platform)
true
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment