Skip to content

Commit

Permalink
chore: Support signoff in autogenerated commits (#21)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Azuma <dazuma@gmail.com>
  • Loading branch information
dazuma committed Sep 2, 2020
1 parent a7ca953 commit 0a20abd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions .toys/.data/releases.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
repo: cloudevents/sdk-ruby
main_branch: master
signoff_commits: true
gems:
- name: cloud_events
docs_builder_tool: [yardoc]
4 changes: 3 additions & 1 deletion .toys/release/.lib/release_perform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ def push_docs
@utils.logger.info "Pushing #{@gem_name} docs to gh-pages ..."
::Dir.chdir @gh_pages_dir do
@utils.exec ["git", "add", "."]
@utils.exec ["git", "commit", "-m", "Generate yardocs for #{@gem_name} #{@gem_version}"]
commit_cmd = ["git", "commit", "-m", "Generate yardocs for #{@gem_name} #{@gem_version}"]
commit_cmd << "--signoff" if @utils.signoff_commits?
@utils.exec commit_cmd
if @dry_run
@utils.logger.info "DRY RUN: Docs pushed to gh-pages"
else
Expand Down
18 changes: 14 additions & 4 deletions .toys/release/.lib/release_prepare.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def analyze_title title
bump_segment = 2
match = /^(fix|feat|docs)(?:\([^()]+\))?(!?):\s+(.*)$/.match title
return bump_segment unless match
description = match[3].gsub(/\(#\d+\)$/, "")
description = normalize_line match[3], delete_pr_number: true
case match[1]
when "fix"
@fixes << description
Expand Down Expand Up @@ -177,7 +177,7 @@ def analyze_body body, bump_segment
case match[1]
when /^BREAKING[-\s]CHANGE$/
bump_segment = 0 unless lock_change
@breaks << match[2]
@breaks << normalize_line(match[2])
when /^semver-change$/i
seg = SEMVER_CHANGES[match[2].downcase]
if seg
Expand All @@ -189,11 +189,19 @@ def analyze_body body, bump_segment
bump_segment
end

def normalize_line line, delete_pr_number: false
match = /^([a-z])(.*)$/.match line
line = match[1].upcase + match[2] if match
line = line.gsub(/\(#\d+\)$/, "") if delete_pr_number
line
end

def determine_new_version
@new_version = @override_version
if @last_version
@new_version ||= begin
segments = @last_version.segments
@bump_segment = 1 if segments[0].zero? && @bump_segment.zero?
segments[@bump_segment] += 1
segments.fill(0, @bump_segment + 1).join(".")
end
Expand All @@ -216,7 +224,7 @@ def build_changelog_entries
@changelog_entries << "* Feature: #{line}"
end
@fixes.each do |line|
@changelog_entries << "* Fixed: #{line}"
@changelog_entries << "* Fix: #{line}"
end
@docs.each do |line|
@changelog_entries << "* Documentation: #{line}"
Expand Down Expand Up @@ -259,7 +267,9 @@ def create_release_commit
@utils.exec ["git", "branch", "-D", @release_branch_name]
end
@utils.exec ["git", "checkout", "-b", @release_branch_name]
@utils.exec ["git", "commit", "-a", "-m", @release_commit_title]
commit_cmd = ["git", "commit", "-a", "-m", @release_commit_title]
commit_cmd << "--signoff" if @utils.signoff_commits?
@utils.exec commit_cmd
@utils.exec ["git", "push", "-f", @git_remote, @release_branch_name]
@utils.exec ["git", "checkout", @release_ref]
end
Expand Down
5 changes: 5 additions & 0 deletions .toys/release/.lib/release_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def repo_owner
repo_path.split("/").first
end

def signoff_commits?
@signoff_commits
end

def all_gems
@gems.keys
end
Expand Down Expand Up @@ -349,6 +353,7 @@ def load_release_info file_path
info = ::YAML.load_file file_path
@main_branch = info["main_branch"] || "main"
@repo_path = info["repo"]
@signoff_commits = info["signoff_commits"] ? true : false
error "Repo key missing from releases.yml" unless @repo_path
@gems = {}
@default_gem = nil
Expand Down

0 comments on commit 0a20abd

Please sign in to comment.