From a5aa75fd04a71cd8236b8c8481a067c0a47b24b9 Mon Sep 17 00:00:00 2001 From: James Couball Date: Fri, 6 Jun 2025 14:46:10 -0700 Subject: [PATCH 1/4] chore: update the project's default branch from 'master' to 'main' --- .github/pull_request_template.md | 2 +- .github/workflows/continuous_integration.yml | 2 +- .github/workflows/enforce_conventional_commits.yml | 2 +- .../experimental_continuous_integration.yml | 2 +- .github/workflows/release.yml | 2 +- README.md | 14 +++++++------- bin/test | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 63e23392..b2c28b62 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,4 +1,4 @@ -Review our [guidelines for contributing](https://github.com/ruby-git/ruby-git/blob/master/CONTRIBUTING.md) to this repository. A good start is to: +Review our [guidelines for contributing](https://github.com/ruby-git/ruby-git/blob/main/CONTRIBUTING.md) to this repository. A good start is to: * Write tests for your changes * Run `rake` before pushing diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index c21e97cd..0e7cd259 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -2,7 +2,7 @@ name: CI on: pull_request: - branches: [master] + branches: [main] workflow_dispatch: jobs: diff --git a/.github/workflows/enforce_conventional_commits.yml b/.github/workflows/enforce_conventional_commits.yml index 8aaa93f8..b995ef1a 100644 --- a/.github/workflows/enforce_conventional_commits.yml +++ b/.github/workflows/enforce_conventional_commits.yml @@ -7,7 +7,7 @@ permissions: on: pull_request: branches: - - master + - main jobs: commit-lint: diff --git a/.github/workflows/experimental_continuous_integration.yml b/.github/workflows/experimental_continuous_integration.yml index 488ab797..b1256714 100644 --- a/.github/workflows/experimental_continuous_integration.yml +++ b/.github/workflows/experimental_continuous_integration.yml @@ -2,7 +2,7 @@ name: CI Experimental on: push: - branches: [master] + branches: [main] workflow_dispatch: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eaea43f1..607f16ce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ description: | on: push: - branches: ["master"] + branches: ["main"] workflow_dispatch: diff --git a/README.md b/README.md index 74e6ad4c..18671023 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![Gem Version](https://badge.fury.io/rb/git.svg)](https://badge.fury.io/rb/git) [![Documentation](https://img.shields.io/badge/Documentation-Latest-green)](https://rubydoc.info/gems/git/) [![Change Log](https://img.shields.io/badge/CHANGELOG-Latest-green)](https://rubydoc.info/gems/git/file/CHANGELOG.md) -[![Build Status](https://github.com/ruby-git/ruby-git/workflows/CI/badge.svg?branch=master)](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI) +[![Build Status](https://github.com/ruby-git/ruby-git/workflows/CI/badge.svg?branch=main)](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org) - [📢 We've Switched to Conventional Commits 📢](#-weve-switched-to-conventional-commits-) @@ -275,8 +275,8 @@ g.branches # returns Git::Branch objects g.branches.local g.current_branch g.branches.remote -g.branches[:master].gcommit -g.branches['origin/master'].gcommit +g.branches[:main].gcommit +g.branches['origin/main'].gcommit g.grep('hello') # implies HEAD g.blob('v2.5:Makefile').grep('hello') @@ -333,7 +333,7 @@ Git.ls_remote('https://github.com/ruby-git/ruby-git.git') # returns a hash conta Git.ls_remote('/path/to/local/repo') Git.ls_remote() # same as Git.ls_remote('.') -Git.default_branch('https://github.com/ruby-git/ruby-git') #=> 'master' +Git.default_branch('https://github.com/ruby-git/ruby-git') #=> 'main' ``` And here are the operations that will need to write to your git repository. @@ -406,13 +406,13 @@ g.branch('new_branch') # creates new or fetches existing g.branch('new_branch').checkout g.branch('new_branch').delete g.branch('existing_branch').checkout -g.branch('master').contains?('existing_branch') +g.branch('main').contains?('existing_branch') # delete remote branch g.push('origin', 'remote_branch_name', force: true, delete: true) g.checkout('new_branch') -g.checkout('new_branch', new_branch: true, start_point: 'master') +g.checkout('new_branch', new_branch: true, start_point: 'main') g.checkout(g.branch('new_branch')) g.branch(name).merge(branch2) @@ -422,7 +422,7 @@ g.branch(name).in_branch(message) { # add files } # auto-commits g.merge('new_branch') g.merge('new_branch', 'merge commit message', no_ff: true) g.merge('origin/remote_branch') -g.merge(g.branch('master')) +g.merge(g.branch('main')) g.merge([branch1, branch2]) g.merge_base('branch1', 'branch2') diff --git a/bin/test b/bin/test index 599ecbd9..3b2e91d2 100755 --- a/bin/test +++ b/bin/test @@ -11,7 +11,7 @@ require 'bundler/setup' `git config --global user.email "git@example.com"` if `git config --global user.email`.empty? `git config --global user.name "GitExample"` if `git config --global user.name`.empty? -`git config --global init.defaultBranch master` if `git config --global init.defaultBranch`.empty? +`git config --global init.defaultBranch main` if `git config --global init.defaultBranch`.empty? project_root = File.expand_path(File.join(__dir__, '..')) From e04f08e202ae54286033b4d0a75c47f124bd63e2 Mon Sep 17 00:00:00 2001 From: James Couball Date: Fri, 6 Jun 2025 14:59:03 -0700 Subject: [PATCH 2/4] chore: announce default branch change in README --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 18671023..f62b42f9 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ [![Build Status](https://github.com/ruby-git/ruby-git/workflows/CI/badge.svg?branch=main)](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org) +- [📢 Default Branch Rename 📢](#-default-branch-rename-) - [📢 We've Switched to Conventional Commits 📢](#-weve-switched-to-conventional-commits-) - [Summary](#summary) - [Install](#install) @@ -21,6 +22,14 @@ - [Ruby version support policy](#ruby-version-support-policy) - [License](#license) +## 📢 Default Branch Rename 📢 + +On June 6th, 2025, the default branch was renamed from 'master' to 'main'. + +Instructions for renaming your local or forked branch to match can be found in the +gist [Default Branch Name +Change](https://gist.github.com/jcouball/580a10e395f7fdfaaa4297bbe816cc7d). + ## 📢 We've Switched to Conventional Commits 📢 To enhance our development workflow, enable automated changelog generation, and pave From 803253ea2dd2b69b099c0d1919b03ac65c800264 Mon Sep 17 00:00:00 2001 From: James Couball Date: Tue, 1 Jul 2025 19:24:20 -0700 Subject: [PATCH 3/4] fix: raise a Git::FailedError if depth < 0 is passed to Git.clone Fixes #805 --- .gitignore | 3 ++- lib/git/lib.rb | 2 +- tests/units/test_git_clone.rb | 45 +++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 13dcea11..29f4b966 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ pkg rdoc Gemfile.lock node_modules -package-lock.json \ No newline at end of file +package-lock.json +ai-prompt.erb diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 692ceef9..5a3ade32 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -126,7 +126,7 @@ def clone(repository_url, directory, opts = {}) arr_opts = [] arr_opts << '--bare' if opts[:bare] arr_opts << '--branch' << opts[:branch] if opts[:branch] - arr_opts << '--depth' << opts[:depth].to_i if opts[:depth] && opts[:depth].to_i > 0 + arr_opts << '--depth' << opts[:depth].to_i if opts[:depth] arr_opts << '--filter' << opts[:filter] if opts[:filter] Array(opts[:config]).each { |c| arr_opts << '--config' << c } arr_opts << '--origin' << opts[:remote] || opts[:origin] if opts[:remote] || opts[:origin] diff --git a/tests/units/test_git_clone.rb b/tests/units/test_git_clone.rb index 24221e38..a5c50ddb 100644 --- a/tests/units/test_git_clone.rb +++ b/tests/units/test_git_clone.rb @@ -159,4 +159,49 @@ def test_git_clone_with_no_name assert_equal(expected_command_line, actual_command_line) end + + test 'clone with negative depth' do + repository_url = 'https://github.com/ruby-git/ruby-git.git' + destination = 'ruby-git' + + actual_command_line = nil + + in_temp_dir do |path| + # Give a bare repository with a single commit + repository_path = File.join(path, 'repository.git') + Git.init(repository_path, :bare => true) + worktree_path = File.join(path, 'repository') + worktree = Git.clone(repository_path, worktree_path) + File.write(File.join(worktree_path, 'test.txt'), 'test') + worktree.add('test.txt') + worktree.commit('Initial commit') + worktree.push + FileUtils.rm_rf(worktree_path) + + # When I clone it with a negative depth with + error = assert_raises(Git::FailedError) do + Git.clone(repository_path, worktree, depth: -1) + end + + assert_match(/depth/, error.result.stderr) + end + + # git = Git.init('.') + + # # Mock the Git::Lib#command method to capture the actual command line args + # git.lib.define_singleton_method(:command) do |cmd, *opts, &block| + # actual_command_line = [cmd, *opts.flatten] + # end + + # git.lib.clone(repository_url, destination, depth: -1) + # end + + # expected_command_line = [ + # 'clone', + # '--depth', '-1', + # '--', repository_url, destination, {timeout: nil} + # ] + + # assert_equal(expected_command_line, actual_command_line) + end end From 03c19fc65e88f9ea60ad87f5141fdc6996ee1464 Mon Sep 17 00:00:00 2001 From: James Couball Date: Tue, 1 Jul 2025 19:33:50 -0700 Subject: [PATCH 4/4] chore: release v3.1.1 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 13 +++++++++++++ lib/git/version.rb | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ada7355e..b4b8d0ff 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.1.0" + ".": "3.1.1" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 5602c70e..feedb6bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ # Change Log +## [3.1.1](https://github.com/ruby-git/ruby-git/compare/v3.1.0...v3.1.1) (2025-07-02) + + +### Bug Fixes + +* Raise a Git::FailedError if depth < 0 is passed to Git.clone ([803253e](https://github.com/ruby-git/ruby-git/commit/803253ea2dd2b69b099c0d1919b03ac65c800264)), closes [#805](https://github.com/ruby-git/ruby-git/issues/805) + + +### Other Changes + +* Announce default branch change in README ([e04f08e](https://github.com/ruby-git/ruby-git/commit/e04f08e202ae54286033b4d0a75c47f124bd63e2)) +* Update the project's default branch from 'master' to 'main' ([a5aa75f](https://github.com/ruby-git/ruby-git/commit/a5aa75fd04a71cd8236b8c8481a067c0a47b24b9)) + ## [3.1.0](https://github.com/ruby-git/ruby-git/compare/v3.0.2...v3.1.0) (2025-05-18) diff --git a/lib/git/version.rb b/lib/git/version.rb index 0a293cc1..a6a12505 100644 --- a/lib/git/version.rb +++ b/lib/git/version.rb @@ -3,5 +3,5 @@ module Git # The current gem version # @return [String] the current gem version. - VERSION='3.1.0' + VERSION='3.1.1' end