Skip to content
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
83 changes: 11 additions & 72 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,79 +1,18 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'English'
require 'rake/clean'

require 'git/version'
# Load all .rake files from tasks and its subdirectories.
Dir.glob('tasks/**/*.rake').each { |r| load r }

default_tasks = []

desc 'Run Unit Tests'
task :test do
sh 'ruby bin/test'

# You can run individual test files (or multiple files) from the command
# line with:
#
# $ bin/test test_archive.rb
#
# $ bin/test test_archive.rb test_object.rb
end
default_tasks << :test

# Rubocop

require 'rubocop/rake_task'

RuboCop::RakeTask.new

default_tasks << :rubocop

# YARD

unless RUBY_PLATFORM == 'java' || RUBY_ENGINE == 'truffleruby'
#
# YARD documentation for this project can NOT be built with JRuby.
# This project uses the redcarpet gem which can not be installed on JRuby.
#
require 'yard'
YARD::Rake::YardocTask.new
CLEAN << '.yardoc'
CLEAN << 'doc'
default_tasks << :yard

require 'yardstick/rake/verify'
Yardstick::Rake::Verify.new(:'yardstick:coverage') do |t|
t.threshold = 50
t.require_exact_threshold = false
end
default_tasks << :'yardstick:coverage'

desc 'Run yardstick to check yard docs'
task :yardstick do
sh "yardstick 'lib/**/*.rb'"
end
# Do not include yardstick as a default task for now since there are too many
# warnings. Will work to get the warnings down before re-enabling it.
#
# default_tasks << :yardstick
end

default_tasks << :build
default_tasks << :test if Rake::Task.task_defined?(:test)
default_tasks << :rubocop if Rake::Task.task_defined?(:rubocop)
default_tasks << :yard if Rake::Task.task_defined?(:yard)
default_tasks << :'yardstick:coverage' if Rake::Task.task_defined?(:'yardstick:coverage')
# Do not include yardstick as a default task for now since there are too many
# warnings. Will work to get the warnings down before re-enabling it.
# default_tasks << :yardstick if Rake::Task.task_defined?(:yardstick)
default_tasks << :build if Rake::Task.task_defined?(:build)

task default: default_tasks

desc 'Build and install the git gem and run a sanity check'
task 'test:gem': :install do
output = `ruby -e "require 'git'; g = Git.open('.'); puts g.log.size"`.chomp
raise 'Gem test failed' unless $CHILD_STATUS.success?
raise 'Expected gem test to return an integer' unless output =~ /^\d+$/

puts 'Gem Test Succeeded'
end

# Make it so that calling `rake release` just calls `rake release:rubygem_push` to
# avoid creating and pushing a new tag.

Rake::Task['release'].clear
desc 'Customized release task to avoid creating a new tag'
task release: 'release:rubygem_push'
2 changes: 1 addition & 1 deletion lib/git/lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def change_head_branch(branch_name)
# The branch's full refname
(?:
(?<not_a_branch>\(not[[:blank:]]a[[:blank:]]branch\)) |
(?:\(HEAD[[:blank:]]detached[[:blank:]]at[[:blank:]](?<detached_ref>[^\)]+)\)) |
(?:\(HEAD[[:blank:]]detached[[:blank:]]at[[:blank:]](?<detached_ref>[^)]+)\)) |
(?<refname>[^[[:blank:]]]+)
)

Expand Down
10 changes: 10 additions & 0 deletions tasks/gem_tasks.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'

# Make it so that calling `rake release` just calls `rake release:rubygem_push` to
# avoid creating and pushing a new tag.

Rake::Task['release'].clear
desc 'Customized release task to avoid creating a new tag'
task release: 'release:rubygem_push'
5 changes: 5 additions & 0 deletions tasks/rubocop.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

require 'rubocop/rake_task'

RuboCop::RakeTask.new
13 changes: 13 additions & 0 deletions tasks/test.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

desc 'Run Unit Tests'
task :test do
sh 'ruby bin/test'

# You can run individual test files (or multiple files) from the command
# line with:
#
# $ bin/test test_archive.rb
#
# $ bin/test test_archive.rb test_object.rb
end
12 changes: 12 additions & 0 deletions tasks/test_gem.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require 'English'

desc 'Build and install the git gem and run a sanity check'
task 'test:gem': :install do
output = `ruby -e "require 'git'; g = Git.open('.'); puts g.log.size"`.chomp
raise 'Gem test failed' unless $CHILD_STATUS.success?
raise 'Expected gem test to return an integer' unless output =~ /^\d+$/

puts 'Gem Test Succeeded'
end
23 changes: 23 additions & 0 deletions tasks/yard.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

# YARD documentation for this project can NOT be built with JRuby or TruffleRuby.
# This project uses the redcarpet gem which can not be installed on JRuby.
#
unless RUBY_PLATFORM == 'java' || RUBY_ENGINE == 'truffleruby'
require 'yard'

YARD::Rake::YardocTask.new
CLEAN << '.yardoc'
CLEAN << 'doc'

require 'yardstick/rake/verify'
Yardstick::Rake::Verify.new(:'yardstick:coverage') do |t|
t.threshold = 50
t.require_exact_threshold = false
end

desc 'Run yardstick to check yard docs'
task :yardstick do
sh "yardstick 'lib/**/*.rb'"
end
end