Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development related cleanup #2018

Merged
merged 3 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
require 'bundler'
Bundler.require
require 'rouge'
require 'minitest/spec'
require 'minitest/autorun'

Token = Rouge::Token
Expand Down
23 changes: 11 additions & 12 deletions tasks/update/changelog.rake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace :update do
desc "Insert lines in CHANGELOG.md for commits between SHAs (inclusive)"
desc "Insert lines in CHANGELOG.md for commits between SHAs (inclusive)"
task :changelog, [:beg_sha, :end_sha] do |t, args|
args.with_defaults(:end_sha => nil)

Expand All @@ -9,33 +9,32 @@ namespace :update do
working_dir = Rake.application.original_dir
repo = Rouge::Tasks::Git.new(working_dir, remote)
gitlog = repo.log(args.beg_sha, args.end_sha)

text = ''
not_inserted = true

File.readlines(changelog).each do |l|
if not_inserted && l.start_with?("##")
text += Rouge::Tasks.version_line(Rouge.version)
text += Rouge::Tasks.comparison_line(remote,
repo.prev_version,
text += Rouge::Tasks.comparison_line(remote,
repo.prev_version,
"v" + Rouge.version)
text += gitlog.converted.join("") + "\n"
not_inserted = false
end

text += l
end

File.write(changelog, text)
end
end

require 'git'

module Rouge
module Tasks
class Git
def initialize(dir, remote)
require 'git'
@repo = ::Git.open(dir)
@remote = remote
end
Expand All @@ -44,7 +43,7 @@ module Rouge
commits = @repo.log(100).between(beg_sha, end_sha)
Log.new(@remote, commits)
end

def prev_version
@prev_version ||= @repo
.tags
Expand All @@ -61,8 +60,8 @@ module Rouge
return a[1] <=> b[1] if a[0] == b[0]
return a[0] <=> b[0]
end
class Log

class Log
def initialize(remote, commits)
@remote = remote
@msgs = commits.map { |c| Message.new(c.message, c.author.name) }
Expand All @@ -85,7 +84,7 @@ module Rouge
end
end
end

def self.comparison_line(remote, previous, current)
"[Comparison with the previous version](https://#{remote}/compare/#{previous}...#{current})\n\n"
end
Expand All @@ -97,7 +96,7 @@ module Rouge
def self.message_line(message)
" - #{message}\n"
end

def self.version_line(version)
"## version #{version}: #{Time.now.strftime("%Y-%m-%d")}\n\n"
end
Expand Down