class Fastlane::Helper::JiraIssuesReleaseNotesHelper
Public Class Methods
extract_key_from_branch(branch:, ticket_prefix:)
click to toggle source
# File lib/fastlane/plugin/jira_issues_release_notes/helper/jira_issues_release_notes_helper.rb, line 183 def self.extract_key_from_branch(branch:, ticket_prefix:) regex = Regexp.new("(#{ticket_prefix}-\\d+)") ticket_code = regex.match branch ticket_code end
format_issue_link(issue:)
click to toggle source
# File lib/fastlane/plugin/jira_issues_release_notes/helper/jira_issues_release_notes_helper.rb, line 10 def self.format_issue_link(issue:) # formats the link according to the output format we need link = @jira_helper.url(issue: issue) case @format when "slack" "*<#{link}|#{issue.key}>*: #{issue.summary}" when "markdown" "- **[#{issue.key}](#{link})**: #{issue.summary}" when "html" " - <strong><a href=\"#{link}\" target=\"_blank\">#{issue.key}</a><strong>: #{issue.summary}" else "- #{issue.key}: #{issue.summary} (#{link})" end end
format_issues(label:, issues:)
click to toggle source
# File lib/fastlane/plugin/jira_issues_release_notes/helper/jira_issues_release_notes_helper.rb, line 176 def self.format_issues(label:, issues:) [ style_text(text: "► #{label}", style: 'heading'), issues.map { |issue| format_issue_link(issue: issue) } ].flatten! end
generate_changelog(groups:, line_break_format:)
click to toggle source
# File lib/fastlane/plugin/jira_issues_release_notes/helper/jira_issues_release_notes_helper.rb, line 164 def self.generate_changelog(groups:, line_break_format:) changelog = [] groups.each do |label, issues| changelog.concat(['']) unless changelog.to_s.empty? changelog.concat(format_issues(label: label, issues: issues)) unless issues.empty? end # changes = format_issues(issues: issues) changelog.join(line_break_format) end
get_commit_after_latest_tag(tag_regex:, tag_version_match:, debug:)
click to toggle source
# File lib/fastlane/plugin/jira_issues_release_notes/helper/jira_issues_release_notes_helper.rb, line 68 def self.get_commit_after_latest_tag(tag_regex:, tag_version_match:, debug:) unless Actions.lane_context[Fastlane::Actions::SharedValues::FL_JIRA_COMMITS_FROM_HASH] then # Try to find the tag command = "git describe --tags --match=#{tag_regex}" tag = Actions.sh(command, log: debug) if tag.empty? UI.message("First commit of the branch is taken as a begining of next release") # If there is no tag found we taking the first commit of current branch hash = Actions.sh('git rev-list --max-parents=0 HEAD', log: debug).chomp else # Tag's format is v2.3.4-5-g7685948 # Get a hash of last version tag tag_name = tag.split('-')[0...-2].join('-').strip parsed_version = tag_name.match(tag_version_match) if parsed_version.nil? UI.user_error!("Error while parsing version from tag #{tag_name} by using tag_version_match - #{tag_version_match}. Please check if the tag contains version as you expect and if you are using single brackets for tag_version_match parameter.") end version = parsed_version[0] # Get a hash of last version tag command = "git rev-list -n 1 refs/tags/#{tag_name}" hash = Actions.sh(command, log: debug).chomp UI.message("Found a tag #{tag_name} associated with version #{version}") end # Get commits log between last version and head commits = git_log( pretty: '%s|%b|>', start: hash, debug: debug ) Actions.lane_context[Fastlane::Actions::SharedValues::FL_JIRA_LAST_TAG] = tag Actions.lane_context[Fastlane::Actions::SharedValues::FL_JIRA_LAST_TAG_HASH] = hash Actions.lane_context[Fastlane::Actions::SharedValues::FL_JIRA_COMMITS_FROM_HASH] = commits end Actions.lane_context[Fastlane::Actions::SharedValues::FL_JIRA_COMMITS_FROM_HASH] rescue StandardError => error UI.error error.message UI.message("Tag was not found for match pattern - #{tag_regex}") nil end
get_issues_from_commit_after_latest_tag(tag_regex:, tag_version_match:, issue_key_regex:, debug:)
click to toggle source
# File lib/fastlane/plugin/jira_issues_release_notes/helper/jira_issues_release_notes_helper.rb, line 139 def self.get_issues_from_commit_after_latest_tag(tag_regex:, tag_version_match:, issue_key_regex:, debug:) unless Actions.lane_context[Fastlane::Actions::SharedValues::FL_JIRA_LAST_ISSUES_FROM_COMMITS] then unless @jira_helper then UI.user_error! "Uninitialized jira client" end keys = get_key_from_commit_after_latest_tag( tag_regex: tag_regex, tag_version_match: tag_version_match, issue_key_regex: issue_key_regex, debug: debug ) issues = @jira_helper.get(keys: keys) Actions.lane_context[Fastlane::Actions::SharedValues::FL_JIRA_LAST_ISSUES_FROM_COMMITS] = issues end Actions.lane_context[Fastlane::Actions::SharedValues::FL_JIRA_LAST_ISSUES_FROM_COMMITS] end
get_key_from_commit_after_latest_tag(tag_regex:, tag_version_match:, issue_key_regex:, debug:)
click to toggle source
# File lib/fastlane/plugin/jira_issues_release_notes/helper/jira_issues_release_notes_helper.rb, line 117 def self.get_key_from_commit_after_latest_tag(tag_regex:, tag_version_match:, issue_key_regex:, debug:) unless Actions.lane_context[Fastlane::Actions::SharedValues::FL_JIRA_LAST_KEYS_FROM_COMMITS] then commits = get_commit_after_latest_tag( tag_regex: tag_regex, tag_version_match: tag_version_match, debug: debug, ) return nil unless commits last_keys_from_commits = commits .to_enum(:scan, issue_key_regex) .map { $& } .reject(&:empty?) .uniq Actions.lane_context[Fastlane::Actions::SharedValues::FL_JIRA_LAST_KEYS_FROM_COMMITS] = last_keys_from_commits end Actions.lane_context[Fastlane::Actions::SharedValues::FL_JIRA_LAST_KEYS_FROM_COMMITS] end
git_log(params)
click to toggle source
# File lib/fastlane/plugin/jira_issues_release_notes/helper/jira_issues_release_notes_helper.rb, line 159 def self.git_log(params) command = "git log --pretty='#{params[:pretty]}' --reverse #{params[:start]}..HEAD" Actions.sh(command, log: params[:debug]).chomp end
initialize_jira(host:, api_version:, username:, password:, context_path:, disable_ssl_verification:)
click to toggle source
# File lib/fastlane/plugin/jira_issues_release_notes/helper/jira_issues_release_notes_helper.rb, line 192 def self.initialize_jira(host:, api_version:, username:, password:, context_path:, disable_ssl_verification:) unless @jira_helper then @jira_helper = jira_helper( host: host, api_version: api_version, username: username, password: password, context_path: context_path, disable_ssl_verification: disable_ssl_verification ) end @jira_helper end
jira_helper(host:, api_version:, username:, password:, context_path:, disable_ssl_verification:)
click to toggle source
# File lib/fastlane/plugin/jira_issues_release_notes/helper/jira_issues_release_notes_helper.rb, line 207 def self.jira_helper(host:, api_version:, username:, password:, context_path:, disable_ssl_verification:) JiraHelper.new( host: host, api_version: api_version, username: username, password: password, context_path: context_path, disable_ssl_verification: disable_ssl_verification ) end
style_text(text:, style:)
click to toggle source
# File lib/fastlane/plugin/jira_issues_release_notes/helper/jira_issues_release_notes_helper.rb, line 25 def self.style_text(text:, style:) # formats the text according to the style we're looking to use # Skips all styling case style when "title" case @format when "markdown" "# #{text}" when "slack" "*#{text}*" when "html" "<h1>#{text}</h1>" else text end when "heading" case @format when "markdown" "### #{text}" when "slack" "*#{text}*" when "html" "<h3>#{text}</h3>" else "#{text}:" end when "bold" case @format when "markdown" "**#{text}**" when "slack" "*#{text}*" when "html" "<strong>#{text}</strong>" else text end else text # catchall, shouldn't be needed end end