From 68d76b87897d3723b4eaf4f31e5d083e98b70fef Mon Sep 17 00:00:00 2001 From: James Couball Date: Thu, 12 Jan 2023 12:45:30 -0800 Subject: [PATCH 1/5] Drop ruby 2.3 build and add 3.1 and 3.2 builds (#607) Signed-off-by: James Couball --- .github/workflows/continuous_integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 34dd49a6..3bfb461a 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [2.3, 2.7, 3.0] + ruby: [2.7, 3.0, 3.1, 3.2] operating-system: [ubuntu-latest] include: - ruby: head From 429f0bb4b7c3a61507e5c0353adf062922a7b8b4 Mon Sep 17 00:00:00 2001 From: James Couball Date: Thu, 12 Jan 2023 12:59:42 -0800 Subject: [PATCH 2/5] Update release instructions (#606) Signed-off-by: James Couball --- RELEASING.md | 118 ++++++++++++++++++++++++++------------------------- git.gemspec | 1 + 2 files changed, 61 insertions(+), 58 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index f43697da..174ac8ef 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -8,61 +8,63 @@ Releasing a new version of the `git` gem requires these steps: - [How to release a new git.gem](#how-to-release-a-new-gitgem) - - [Prepare the release](#prepare-the-release) - - [Create a GitHub release](#create-a-github-release) - - [Build and release the gem](#build-and-release-the-gem) - -These instructions use an example where the current release version is `1.5.0` -and the new release version to be created is `1.6.0.pre1`. - -## Prepare the release - -From a fork of ruby-git, create a PR containing changes to (1) bump the -version number, (2) update the CHANGELOG.md, and (3) tag the release. - -- Bump the version number in lib/git/version.rb following [Semantic Versioning](https://semver.org) - guidelines -- Add a link in CHANGELOG.md to the release tag which will be created later - in this guide -- Create a new tag using [git-extras](https://github.com/tj/git-extras/blob/master/Commands.md#git-release) - `git release` command - - For example: `git release v1.6.0.pre1` -- These should be the only changes in the PR -- An example of these changes for `v1.6.0.pre1` can be found in [PR #435](https://github.com/ruby-git/ruby-git/pull/435) -- Get the PR reviewed, approved and merged to master. - -## Create a GitHub release - -On [the ruby-git releases page](https://github.com/ruby-git/ruby-git/releases), -select `Draft a new release` - -- Select the tag corresponding to the version being released `v1.6.0.pre1` -- The Target should be `master` -- For the release description, use the output of [changelog-rs](https://github.com/perlun/changelog-rs) - - A Docker image is provided in [Dockerfile.changelog-rs](https://github.com/ruby-git/ruby-git/blob/master/Dockerfile.changelog-rs) - so you don't have to install changelog-rs or the Rust tool chain. To build the - Docker image, run this command from this project's root directory: - - `docker build --file Dockerfile.changelog-rs --tag changelog-rs .` - - To run the changelog-rs command using this image, run the following command - from this project's root directory (replace the tag names appropriate for the - current release): - - `docker run --rm --volume "$PWD:/worktree" changelog-rs v1.5.0 v1.6.0.pre1` - - Copy the output, omitting the tag header `## v1.6.0.pre1` and paste into - the release description - - The release description can be edited later if needed -- Select the appropriate value for `This is a pre-release` - - Since `v1.6.0.pre1` is a pre-release, check `This is a pre-release` - -## Build and release the gem - -Clone [ruby-git/ruby-git](https://github.com/ruby-git/ruby-git) directly (not a -fork) and ensure your local working copy is on the master branch - -- Verify that you are not on a fork with the command `git remote -v` -- Verify that the version number is correct by running `rake -T` and inspecting - the output for the `release[remote]` task - -Build the git gem and push it to rubygems.org with the command `rake release` - -- Ensure that your `gem sources list` includes `https://rubygems.org` (in my - case, I usually have my work’s internal gem repository listed) + - [Install Prerequisites](#install-prerequisites) + - [Prepare the Release](#prepare-the-release) + - [Review and Merge the Release](#review-and-merge-the-release) + - [Build and Release the Gem](#build-and-release-the-gem) + +These instructions use an example where: + +- The default branch is `master` +- The current release version is `1.5.0` +- You want to create a new *minor* release, `1.6.0` + +## Install Prerequisites + +The following tools need to be installed in order to create the release: + +- [git](https://git-scm.com) is used to interact with the local and remote repositories +- [gh](https://cli.github.com) is used to create the release and PR in GitHub +- [Docker](https://www.docker.com) is used to run the script to create the release notes + +On a Mac, these tools can be installed using [brew](https://brew.sh): + +```shell +$ brew install git +... +$ brew install gh +... +$ brew install --cask docker +... +$ +``` + +## Prepare the Release + +Bump the version, create release notes, tag the release and create a GitHub release and PR which can be used to review the release. + +Steps: + +- Check out the code with `git clone https://github.com/ruby-git/ruby-git ruby-git-v1.6.0 && cd ruby-git-v1.6.0` +- Install development dependencies using bundle `bundle install` +- Based upon the nature of the changes, decide on the type of release: `major`, `minor`, or `patch` (in this example we will use `minor`) +- Run the release script `bundle exec create-github-realese minor` + +## Review and Merge the Release + +Have the release PR approved and merge the changes into the `master` branch. + +**IMPORTANT** DO NOT merge to the `master` branch using the GitHub UI. Instead use the instructions below. + +Steps: + +- Get the release PR reviewed and approved in GitHub +- Merge the changes with the command `git checkout master && git merge --ff-only v1.6.0 && git push` + +## Build and Release the Gem + +Build the gem and publish it to [rubygems.org](https://rubygems.org/gems/git) + +Steps: + +- Build and release the gem using rake `bundle exec rake release` diff --git a/git.gemspec b/git.gemspec index f53ea98d..50b9c140 100644 --- a/git.gemspec +++ b/git.gemspec @@ -30,6 +30,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'rchardet', '~> 1.8' s.add_development_dependency 'bump', '~> 0.10' + s.add_development_dependency 'create_github_release', '~> 0.2' s.add_development_dependency 'minitar', '~> 0.9' s.add_development_dependency 'rake', '~> 13.0' s.add_development_dependency 'test-unit', '~> 3.3' From 23a0ac4b64243d3442f21c23d611d85dc6b865a8 Mon Sep 17 00:00:00 2001 From: James Couball Date: Thu, 12 Jan 2023 13:15:02 -0800 Subject: [PATCH 3/5] Fix version parsing (#605) Signed-off-by: James Couball --- lib/git/lib.rb | 12 +++++---- .../units/test_lib_meets_required_version.rb | 27 +++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 293f2878..b4d16152 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -63,8 +63,6 @@ def initialize(base = nil, logger = nil) @git_work_dir = base[:working_directory] end @logger = logger - - Git::Lib.warn_if_old_command(self) end # creates or reinitializes the repository @@ -1029,8 +1027,9 @@ def archive(sha, file = nil, opts = {}) # returns the current version of git, as an Array of Fixnums. def current_command_version output = command('version') - version = output[/\d+\.\d+(\.\d+)+/] - version.split('.').collect {|i| i.to_i} + version = output[/\d+(\.\d+)+/] + version_parts = version.split('.').collect { |i| i.to_i } + version_parts.fill(0, version_parts.length...3) end def required_command_version @@ -1043,10 +1042,11 @@ def meets_required_version? def self.warn_if_old_command(lib) return true if @version_checked + @version_checked = true unless lib.meets_required_version? $stderr.puts "[WARNING] The git gem requires git #{lib.required_command_version.join('.')} or later, but only found #{lib.current_command_version.join('.')}. You should probably upgrade." end - @version_checked = true + true end private @@ -1104,6 +1104,8 @@ def with_custom_env_variables(&block) end def command(cmd, *opts, &block) + Git::Lib.warn_if_old_command(self) + command_opts = { chomp: true, redirect: '' } if opts.last.is_a?(Hash) command_opts.merge!(opts.pop) diff --git a/tests/units/test_lib_meets_required_version.rb b/tests/units/test_lib_meets_required_version.rb index fce57241..1f572d31 100644 --- a/tests/units/test_lib_meets_required_version.rb +++ b/tests/units/test_lib_meets_required_version.rb @@ -21,4 +21,31 @@ def test_with_old_command_version lib.define_singleton_method(:current_command_version) { [major_version, minor_version] } assert !lib.meets_required_version? end + + def test_parse_version + lib = Git::Lib.new(nil, nil) + + versions_to_test = [ + { version_string: 'git version 2.1', expected_result: [2, 1, 0] }, + { version_string: 'git version 2.28.4', expected_result: [2, 28, 4] }, + { version_string: 'git version 2.32.GIT', expected_result: [2, 32, 0] }, + ] + + lib.instance_variable_set(:@next_version_index, 0) + + lib.define_singleton_method(:command) do |cmd, *opts, &block| + raise ArgumentError unless cmd == 'version' + versions_to_test[@next_version_index][:version_string].tap { @next_version_index += 1 } + end + + lib.define_singleton_method(:next_version_index) { @next_version_index } + + expected_version = versions_to_test[lib.next_version_index][:expected_result] + actual_version = lib.current_command_version + assert_equal(expected_version, actual_version) + + expected_version = versions_to_test[lib.next_version_index][:expected_result] + actual_version = lib.current_command_version + assert_equal(expected_version, actual_version) + end end From 667b83056dffb3c4e10a054e0933332dbb3dfa3f Mon Sep 17 00:00:00 2001 From: James Couball Date: Thu, 12 Jan 2023 13:52:19 -0800 Subject: [PATCH 4/5] Update the GitHub Action step "actions/checkout" from v2 to v3 (#608) Signed-off-by: James Couball --- .github/workflows/continuous_integration.yml | 2 +- RELEASING.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 3bfb461a..302c5eed 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -34,7 +34,7 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Ruby uses: ruby/setup-ruby@v1 diff --git a/RELEASING.md b/RELEASING.md index 174ac8ef..04e11984 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -48,7 +48,7 @@ Steps: - Check out the code with `git clone https://github.com/ruby-git/ruby-git ruby-git-v1.6.0 && cd ruby-git-v1.6.0` - Install development dependencies using bundle `bundle install` - Based upon the nature of the changes, decide on the type of release: `major`, `minor`, or `patch` (in this example we will use `minor`) -- Run the release script `bundle exec create-github-realese minor` +- Run the release script `bundle exec create-github-release minor` ## Review and Merge the Release From 28aa69f34f6e05ebae5731eb34c82a3659136e35 Mon Sep 17 00:00:00 2001 From: James Couball Date: Thu, 12 Jan 2023 13:56:04 -0800 Subject: [PATCH 5/5] Release v1.13.1 Signed-off-by: James Couball --- CHANGELOG.md | 9 +++++++++ lib/git/version.rb | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3c3bd4f..c4780165 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ # Change Log +## v1.13.1 (2023-01-12) + +[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.13.0...v1.13.1) + +* 667b830 Update the GitHub Action step "actions/checkout" from v2 to v3 (#608) +* 23a0ac4 Fix version parsing (#605) +* 429f0bb Update release instructions (#606) +* 68d76b8 Drop ruby 2.3 build and add 3.1 and 3.2 builds (#607) + ## v1.13.0 (2022-12-10) [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.12.0...v1.13.0) diff --git a/lib/git/version.rb b/lib/git/version.rb index bd53cc7c..7f9a45d6 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.13.0' + VERSION='1.13.1' end