Created
May 8, 2019 10:37
-
-
Save matsuda/8aa423ae9ddfa5779a52a17a90807b4d to your computer and use it in GitHub Desktop.
指定されたブランチを取得するlane
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
############################### | |
# get latest release git branch | |
############################### | |
desc "get latest release git branch" | |
private_lane :git_latest_release_branch do | |
pattern = "release\/(.+)" | |
branches = git_find_branches(pattern: pattern) | |
reg = Regexp.new(pattern) | |
branches = branches.sort { |a, b| | |
old_version = a.match(reg)[1] | |
new_version = b.match(reg)[1] | |
Gem::Version.create(new_version) <=> Gem::Version.create(old_version) | |
} | |
branches.first | |
end | |
############################### | |
# get specifed git branch | |
# | |
# :pattern | |
############################### | |
desc "get specifed git branch" | |
private_lane :git_find_branches do |options| | |
pattern = options[:pattern] | |
UI.user_error!("Not found pattern to find") unless pattern | |
reg = Regexp.new(pattern) | |
branches = git_all_branches | |
branches.select { |b| b =~ reg } | |
end | |
############################### | |
# get all git branch list | |
############################### | |
desc "get all git branch list" | |
private_lane :git_all_branches do | |
branches = Actions.sh("git branch") | |
branches.split("\n").map { |b| b.gsub(/\*?\s+/, "") } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment