From d1b17118ff69bf6913ddb27a7f2ffbb77d639da0 Mon Sep 17 00:00:00 2001 From: James Couball Date: Sun, 10 Jan 2021 18:13:20 -0800 Subject: [PATCH 1/9] Add gem build, install, and sanity test to CI build (#509) Signed-off-by: James Couball --- .github/workflows/continuous_integration.yml | 3 ++ CONTRIBUTING.md | 14 ++++---- Rakefile | 38 ++++++++++++++++++++ 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index c50680c8..ad2ea03a 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -40,3 +40,6 @@ jobs: - name: Run Build run: bundle exec rake default + + - name: Test Gem + run: bundle exec rake test:gem diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 929b80b2..4f147fe0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,12 +78,14 @@ In order to ensure high quality, all pull requests must meet these requirements: ### Unit tests * All changes must be accompanied by new or modified unit tests - * The entire test suite must pass when `bundle exec rake test` is run from the - project's local working copy - -### Continuous Integration - * All tests must pass in the project's [Travis CI](https://travis-ci.org/ruby-git/ruby-git) - build before the pull request will be merged + * The entire test suite must pass when `bundle exec rake default` is run from the + project's local working copy. + +### Continuous integration + * All tests must pass in the project's [GitHub Continuous Integration build](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI) + before the pull request will be merged. + * The [Continuous Integration workflow](https://github.com/ruby-git/ruby-git/blob/master/.github/workflows/continuous_integration.yml) + runs both `bundle exec rake default` and `bundle exec rake test:gem` from the project's [Rakefile](https://github.com/ruby-git/ruby-git/blob/master/Rakefile). ### Documentation * New and updated public methods must have [YARD](https://yardoc.org/) diff --git a/Rakefile b/Rakefile index cda2f8cf..730e580a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,5 @@ require 'bundler/gem_tasks' +require 'English' require "#{File.expand_path(File.dirname(__FILE__))}/lib/git/version" @@ -41,4 +42,41 @@ unless RUBY_PLATFORM == 'java' # default_tasks << :yardstick end +if RUBY_PLATFORM == 'java' && Gem.win_platform? + # Reimplement the :build and :install task for JRuby on Windows + # There is a bug in JRuby on Windows that makes the `build` task from `bundler/gem_tasks` fail. + # Once https://github.com/jruby/jruby/issues/6516 is fixed, this block can be deleted. + version = Git::VERSION + pkg_name = 'git' + gem_file = "pkg/#{pkg_name}-#{version}.gem" + + Rake::Task[:build].clear + task :build do + FileUtils.mkdir 'pkg' unless File.exist? 'pkg' + `gem build #{pkg_name}.gemspec --output "#{gem_file}" --quiet` + raise 'Gem build failed' unless $CHILD_STATUS.success? + puts "#{pkg_name} #{version} built to #{gem_file}." + end + + Rake::Task[:install].clear + task :install => :build do + `gem install #{gem_file} --quiet` + raise 'Gem install failed' unless $CHILD_STATUS.success? + puts "#{pkg_name} (#{version}) installed." + end + + CLOBBER << gem_file +end + +default_tasks << :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 From bd026d39b17e192e8a710744153ed28139cc64a7 Mon Sep 17 00:00:00 2001 From: James Couball Date: Fri, 15 Jan 2021 14:32:20 -0800 Subject: [PATCH 2/9] Remove JRuby on Windows workaround (#511) Signed-off-by: James Couball --- Rakefile | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/Rakefile b/Rakefile index 730e580a..acfa2bb0 100644 --- a/Rakefile +++ b/Rakefile @@ -42,32 +42,6 @@ unless RUBY_PLATFORM == 'java' # default_tasks << :yardstick end -if RUBY_PLATFORM == 'java' && Gem.win_platform? - # Reimplement the :build and :install task for JRuby on Windows - # There is a bug in JRuby on Windows that makes the `build` task from `bundler/gem_tasks` fail. - # Once https://github.com/jruby/jruby/issues/6516 is fixed, this block can be deleted. - version = Git::VERSION - pkg_name = 'git' - gem_file = "pkg/#{pkg_name}-#{version}.gem" - - Rake::Task[:build].clear - task :build do - FileUtils.mkdir 'pkg' unless File.exist? 'pkg' - `gem build #{pkg_name}.gemspec --output "#{gem_file}" --quiet` - raise 'Gem build failed' unless $CHILD_STATUS.success? - puts "#{pkg_name} #{version} built to #{gem_file}." - end - - Rake::Task[:install].clear - task :install => :build do - `gem install #{gem_file} --quiet` - raise 'Gem install failed' unless $CHILD_STATUS.success? - puts "#{pkg_name} (#{version}) installed." - end - - CLOBBER << gem_file -end - default_tasks << :build task default: default_tasks From e2fd4af0e8cf6721ebcb14bba8810a6eafa15ab4 Mon Sep 17 00:00:00 2001 From: James Couball Date: Mon, 18 Jan 2021 12:48:26 -0800 Subject: [PATCH 3/9] test: git show should not chomp results (#513) Refs #503 Signed-off-by: James Couball --- tests/units/test_show.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/units/test_show.rb diff --git a/tests/units/test_show.rb b/tests/units/test_show.rb new file mode 100644 index 00000000..c44d81d4 --- /dev/null +++ b/tests/units/test_show.rb @@ -0,0 +1,20 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../test_helper' + +class TestShow < Test::Unit::TestCase + def test_do_not_chomp_contents + in_temp_dir do + file_name = 'README.md' + expected_contents = "hello\nworld\n\n" + + g = Git.init + g.commit('Initial commit', allow_empty: true) + new_file(file_name, expected_contents) + g.add(file_name) + # Show the file from the index by prefixing the file namne with a colon + contents = g.show(":#{file_name}") + assert_equal(expected_contents, contents) + end + end +end From 98270b66b09a9474d6c0ad6d83f384fb4596428a Mon Sep 17 00:00:00 2001 From: yancyribbens Date: Sat, 27 Mar 2021 16:02:19 -0500 Subject: [PATCH 4/9] use spaces instead of tab (#517) Signed-off-by: Yancy --- lib/git/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git/base.rb b/lib/git/base.rb index fbca5f1b..50459215 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -387,7 +387,7 @@ def each_conflict(&block) # :yields: file, your_version, their_version # @git.pull('upstream', 'develope') # pulls from upstream/develop # def pull(remote='origin', branch='master') - self.lib.pull(remote, branch) + self.lib.pull(remote, branch) end # returns an array of Git:Remote objects From 8cd523afa9393d2347da05db13fba1b9852ade4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aldo=20Rinc=C3=B3n=20Mora?= Date: Sat, 19 Jun 2021 18:34:37 +0200 Subject: [PATCH 5/9] Add "g.current_branch" to Readme.md (#519) In my opinion .current_branch is a fairly common operation, and it would be nice to have it listed on the readme file. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0ff9a0a5..bc651c34 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ g.revparse('v2.5:Makefile') g.branches # returns Git::Branch objects g.branches.local +g.current_branch g.branches.remote g.branches[:master].gcommit g.branches['origin/master'].gcommit From 765df7c3d2831203863748e58c46dca0574b83db Mon Sep 17 00:00:00 2001 From: Valentino Stoll Date: Sat, 19 Jun 2021 12:56:25 -0400 Subject: [PATCH 6/9] Adds file option to config_set to allow adding to specific git-config files (#458) Signed-off-by: Valentino Stoll Co-authored-by: James Couball --- lib/git/base.rb | 9 +++++---- lib/git/lib.rb | 8 ++++++-- tests/units/test_config.rb | 17 +++++++++++++++-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/lib/git/base.rb b/lib/git/base.rb index 50459215..6e7c7a10 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -137,13 +137,14 @@ def chdir # :yields: the Git::Path #g.config('user.name', 'Scott Chacon') # sets value #g.config('user.email', 'email@email.com') # sets value + #g.config('user.email', 'email@email.com', file: 'path/to/custom/config) # sets value in file #g.config('user.name') # returns 'Scott Chacon' #g.config # returns whole config hash - def config(name = nil, value = nil) - if(name && value) + def config(name = nil, value = nil, options = {}) + if name && value # set value - lib.config_set(name, value) - elsif (name) + lib.config_set(name, value, options) + elsif name # return value lib.config_get(name) else diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 191b8a74..ce8c141b 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -583,8 +583,12 @@ def show(objectish=nil, path=nil) ## WRITE COMMANDS ## - def config_set(name, value) - command('config', name, value) + def config_set(name, value, options = {}) + if options[:file].to_s.empty? + command('config', name, value) + else + command('config', '--file', options[:file], name, value) + end end def global_config_set(name, value) diff --git a/tests/units/test_config.rb b/tests/units/test_config.rb index a1753831..c04c8530 100644 --- a/tests/units/test_config.rb +++ b/tests/units/test_config.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../test_helper' +require_relative '../test_helper' class TestConfig < Test::Unit::TestCase def setup @@ -26,7 +26,20 @@ def test_set_config g.config('user.name', 'bully') assert_equal('bully', g.config('user.name')) end - end + end + + def test_set_config_with_custom_file + in_temp_dir do |_path| + custom_config_path = "#{Dir.pwd}/bare/.git/custom-config" + g = Git.clone(@wbare, 'bare') + assert_not_equal('bully', g.config('user.name')) + g.config('user.name', 'bully', file: custom_config_path) + assert_not_equal('bully', g.config('user.name')) + g.config('include.path', custom_config_path) + assert_equal('bully', g.config('user.name')) + assert_equal("[user]\n\tname = bully\n", File.read(custom_config_path)) + end + end def test_env_config with_custom_env_variables do From 0cef8ac3f2c912c35c12857f26240222c0f13b72 Mon Sep 17 00:00:00 2001 From: Othmane EL MASSARI <47815944+othmane399@users.noreply.github.com> Date: Sat, 19 Jun 2021 19:04:24 +0200 Subject: [PATCH 7/9] feat: add --gpg-sign option on commits (#518) Add --gpg-sign option on commits Signed-off-by: othmane399 --- lib/git/lib.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/git/lib.rb b/lib/git/lib.rb index ce8c141b..8dcb4f8a 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -646,6 +646,7 @@ def remove(path = '.', opts = {}) # :date # :no_verify # :allow_empty_message + # :gpg_sign # # @param [String] message the commit message to be used # @param [Hash] opts the commit options to be used @@ -659,6 +660,7 @@ def commit(message, opts = {}) arr_opts << "--date=#{opts[:date]}" if opts[:date].is_a? String arr_opts << '--no-verify' if opts[:no_verify] arr_opts << '--allow-empty-message' if opts[:allow_empty_message] + arr_opts << '--gpg-sign' if opts[:gpg_sign] == true || "--gpg-sign=#{opts[:gpg_sign]}" if opts[:gpg_sign] command('commit', arr_opts) end From 8fe479bbdb8b7f3f0eb83d295b6cf6b869a098f9 Mon Sep 17 00:00:00 2001 From: James Couball Date: Mon, 5 Jul 2021 17:30:51 -0700 Subject: [PATCH 8/9] Fix worktree test when git dir includes symlinks (#522) Signed-off-by: James Couball --- tests/units/test_worktree.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/units/test_worktree.rb b/tests/units/test_worktree.rb index 2b509726..f5141c8d 100644 --- a/tests/units/test_worktree.rb +++ b/tests/units/test_worktree.rb @@ -32,23 +32,24 @@ def create_temp_repo(clone_path) def setup @git = Git.open(git_working_dir) - + @commit = @git.object('1cc8667014381') @tree = @git.object('1cc8667014381^{tree}') @blob = @git.object('v2.5:example.txt') - + @worktrees = @git.worktrees end - + def test_worktrees_all assert(@git.worktrees.is_a?(Git::Worktrees)) assert(@git.worktrees.first.is_a?(Git::Worktree)) assert_equal(@git.worktrees.size, 2) end - + def test_worktrees_single worktree = @git.worktrees.first - assert_equal(worktree.dir, @git.dir.to_s) + git_dir = Pathname.new(@git.dir.to_s).realpath.to_s + assert_equal(worktree.dir, git_dir) assert_equal(worktree.gcommit, SAMPLE_LAST_COMMIT) end From 07a1167d4706ba4a66ab3025229ca4ed844a934d Mon Sep 17 00:00:00 2001 From: James Couball Date: Tue, 6 Jul 2021 12:29:17 -0700 Subject: [PATCH 9/9] Release v1.9.0 (#524) Signed-off-by: James Couball Co-authored-by: James Couball --- CHANGELOG.md | 4 ++++ lib/git/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7e7963b..ae998e92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ # Change Log +## 1.9.0 + +See https://github.com/ruby-git/ruby-git/releases/tag/v1.9.0 + ## 1.8.1 See https://github.com/ruby-git/ruby-git/releases/tag/v1.8.1 diff --git a/lib/git/version.rb b/lib/git/version.rb index 05b60fb1..6fe493dc 100644 --- a/lib/git/version.rb +++ b/lib/git/version.rb @@ -1,5 +1,5 @@ module Git # The current gem version # @return [String] the current gem version. - VERSION='1.8.1' + VERSION='1.9.0' end