git 1.19.1 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.commitlintrc.yml +38 -0
  3. data/.github/pull_request_template.md +8 -0
  4. data/.github/workflows/continuous_integration.yml +19 -21
  5. data/.github/workflows/enforce_conventional_commits.yml +28 -0
  6. data/.github/workflows/experimental_continuous_integration.yml +50 -0
  7. data/.github/workflows/release.yml +52 -0
  8. data/.gitignore +3 -0
  9. data/.husky/commit-msg +1 -0
  10. data/.release-please-manifest.json +3 -0
  11. data/.yardopts +0 -1
  12. data/CHANGELOG.md +211 -0
  13. data/CONTRIBUTING.md +290 -102
  14. data/README.md +180 -62
  15. data/Rakefile +7 -0
  16. data/git.gemspec +11 -11
  17. data/lib/git/author.rb +3 -2
  18. data/lib/git/base.rb +222 -59
  19. data/lib/git/branch.rb +2 -0
  20. data/lib/git/branches.rb +15 -14
  21. data/lib/git/command_line.rb +287 -0
  22. data/lib/git/config.rb +7 -1
  23. data/lib/git/diff.rb +2 -0
  24. data/lib/git/errors.rb +206 -0
  25. data/lib/git/escaped_path.rb +1 -1
  26. data/lib/git/index.rb +2 -1
  27. data/lib/git/lib.rb +604 -234
  28. data/lib/git/log.rb +74 -6
  29. data/lib/git/object.rb +80 -76
  30. data/lib/git/path.rb +9 -8
  31. data/lib/git/remote.rb +2 -0
  32. data/lib/git/repository.rb +2 -0
  33. data/lib/git/stash.rb +7 -6
  34. data/lib/git/stashes.rb +11 -10
  35. data/lib/git/status.rb +135 -25
  36. data/lib/git/version.rb +3 -1
  37. data/lib/git/working_directory.rb +2 -0
  38. data/lib/git/worktree.rb +2 -0
  39. data/lib/git/worktrees.rb +2 -0
  40. data/lib/git.rb +21 -7
  41. data/package.json +10 -0
  42. data/release-please-config.json +36 -0
  43. metadata +52 -38
  44. data/.github/stale.yml +0 -25
  45. data/Dockerfile.changelog-rs +0 -12
  46. data/PULL_REQUEST_TEMPLATE.md +0 -9
  47. data/RELEASING.md +0 -70
  48. data/lib/git/base/factory.rb +0 -99
  49. data/lib/git/failed_error.rb +0 -53
  50. data/lib/git/git_execute_error.rb +0 -7
  51. data/lib/git/signaled_error.rb +0 -50
  52. /data/{ISSUE_TEMPLATE.md → .github/issue_template.md} +0 -0
data/CONTRIBUTING.md CHANGED
@@ -3,161 +3,349 @@
3
3
  # @title How To Contribute
4
4
  -->
5
5
 
6
- # Contributing to ruby-git
7
-
8
- Thank you for your interest in contributing to the ruby-git project.
9
-
10
- This document gives the guidelines for contributing to the ruby-git project.
11
- These guidelines may not fit every situation. When contributing use your best
12
- judgement.
13
-
14
- Propose changes to these guidelines with a pull request.
6
+ # Contributing to the git gem
7
+
8
+ - [Summary](#summary)
9
+ - [How to contribute](#how-to-contribute)
10
+ - [How to report an issue or request a feature](#how-to-report-an-issue-or-request-a-feature)
11
+ - [How to submit a code or documentation change](#how-to-submit-a-code-or-documentation-change)
12
+ - [Commit your changes to a fork of `ruby-git`](#commit-your-changes-to-a-fork-of-ruby-git)
13
+ - [Create a pull request](#create-a-pull-request)
14
+ - [Get your pull request reviewed](#get-your-pull-request-reviewed)
15
+ - [Design philosophy](#design-philosophy)
16
+ - [Direct mapping to git commands](#direct-mapping-to-git-commands)
17
+ - [Parameter naming](#parameter-naming)
18
+ - [Output processing](#output-processing)
19
+ - [Coding standards](#coding-standards)
20
+ - [Commit message guidelines](#commit-message-guidelines)
21
+ - [What does this mean for contributors?](#what-does-this-mean-for-contributors)
22
+ - [What to know about Conventional Commits](#what-to-know-about-conventional-commits)
23
+ - [Unit tests](#unit-tests)
24
+ - [Continuous integration](#continuous-integration)
25
+ - [Documentation](#documentation)
26
+ - [Building a specific version of the Git command-line](#building-a-specific-version-of-the-git-command-line)
27
+ - [Install pre-requisites](#install-pre-requisites)
28
+ - [Obtain Git source code](#obtain-git-source-code)
29
+ - [Build git](#build-git)
30
+ - [Use the new Git version](#use-the-new-git-version)
31
+ - [Licensing](#licensing)
32
+
33
+ ## Summary
34
+
35
+ Thank you for your interest in contributing to the `ruby-git` project.
36
+
37
+ This document provides guidelines for contributing to the `ruby-git` project. While
38
+ these guidelines may not cover every situation, we encourage you to use your best
39
+ judgment when contributing.
40
+
41
+ If you have suggestions for improving these guidelines, please propose changes via a
42
+ pull request.
15
43
 
16
44
  ## How to contribute
17
45
 
18
- You can contribute in two ways:
46
+ You can contribute in the following ways:
19
47
 
20
- 1. [Report an issue or make a feature request](#how-to-report-an-issue-or-make-a-feature-request)
21
- 2. [Submit a code or documentation change](#how-to-submit-a-code-or-documentation-change)
48
+ 1. [Report an issue or request a
49
+ feature](#how-to-report-an-issue-or-request-a-feature)
50
+ 2. [Submit a code or documentation
51
+ change](#how-to-submit-a-code-or-documentation-change)
22
52
 
23
- ## How to report an issue or make a feature request
53
+ ## How to report an issue or request a feature
24
54
 
25
- ruby-git utilizes [GitHub Issues](https://help.github.com/en/github/managing-your-work-on-github/about-issues)
55
+ `ruby-git` utilizes [GitHub
56
+ Issues](https://help.github.com/en/github/managing-your-work-on-github/about-issues)
26
57
  for issue tracking and feature requests.
27
58
 
28
- Report an issue or feature request by [creating a ruby-git Github issue](https://github.com/ruby-git/ruby-git/issues/new).
29
- Fill in the template to describe the issue or feature request the best you can.
59
+ To report an issue or request a feature, please [create a `ruby-git` GitHub
60
+ issue](https://github.com/ruby-git/ruby-git/issues/new). Fill in the template as
61
+ thoroughly as possible to describe the issue or feature request.
30
62
 
31
63
  ## How to submit a code or documentation change
32
64
 
33
- There is three step process for code or documentation changes:
65
+ There is a three-step process for submitting code or documentation changes:
34
66
 
35
- 1. [Commit your changes to a fork of ruby-git](#commit-changes-to-a-fork-of-ruby-git)
67
+ 1. [Commit your changes to a fork of
68
+ `ruby-git`](#commit-your-changes-to-a-fork-of-ruby-git) using [Conventional
69
+ Commits](#commit-message-guidelines)
36
70
  2. [Create a pull request](#create-a-pull-request)
37
71
  3. [Get your pull request reviewed](#get-your-pull-request-reviewed)
38
72
 
39
- ### Commit changes to a fork of ruby-git
73
+ ### Commit your changes to a fork of `ruby-git`
40
74
 
41
- Make your changes in a fork of the ruby-git repository.
42
-
43
- Each commit must include a [DCO sign-off](#developer-certificate-of-origin-dco)
44
- by adding the line `Signed-off-by: Name <email>` to the end of the commit
45
- message.
75
+ Make your changes in a fork of the `ruby-git` repository.
46
76
 
47
77
  ### Create a pull request
48
78
 
49
- See [this article](https://help.github.com/articles/about-pull-requests/) if you
50
- are not familiar with GitHub Pull Requests.
79
+ If you are not familiar with GitHub Pull Requests, please refer to [this
80
+ article](https://help.github.com/articles/about-pull-requests/).
51
81
 
52
82
  Follow the instructions in the pull request template.
53
83
 
54
84
  ### Get your pull request reviewed
55
85
 
56
- Code review takes place in a GitHub pull request using the [the Github pull request review feature](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-reviews).
86
+ Code review takes place in a GitHub pull request using the [GitHub pull request
87
+ review
88
+ feature](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-reviews).
57
89
 
58
90
  Once your pull request is ready for review, request a review from at least one
59
- [maintainer](MAINTAINERS.md) and any number of other contributors.
91
+ [maintainer](MAINTAINERS.md) and any other contributors you deem necessary.
92
+
93
+ During the review process, you may need to make additional commits, which should be
94
+ squashed. Additionally, you may need to rebase your branch to the latest `master`
95
+ branch if other changes have been merged.
96
+
97
+ At least one approval from a project maintainer is required before your pull request
98
+ can be merged. The maintainer is responsible for ensuring that the pull request meets
99
+ [the project's coding standards](#coding-standards).
100
+
101
+ ## Design philosophy
102
+
103
+ *Note: As of v2.x of the `git` gem, this design philosophy is aspirational. Future
104
+ versions may include interface changes to fully align with these principles.*
105
+
106
+ The `git` gem is designed as a lightweight wrapper around the `git` command-line
107
+ tool, providing Ruby developers with a simple and intuitive interface for
108
+ programmatically interacting with Git.
109
+
110
+ This gem adheres to the "principle of least surprise," ensuring that it does not
111
+ introduce unnecessary abstraction layers or modify Git's core functionality. Instead,
112
+ the gem maintains a close alignment with the existing `git` command-line interface,
113
+ avoiding extensions or alterations that could lead to unexpected behaviors.
114
+
115
+ By following this philosophy, the `git` gem allows users to leverage their existing
116
+ knowledge of Git while benefiting from the expressiveness and power of Ruby's syntax
117
+ and paradigms.
118
+
119
+ ### Direct mapping to git commands
120
+
121
+ Git commands are implemented within the `Git::Base` class, with each method directly
122
+ corresponding to a `git` command. When a `Git::Base` object is instantiated via
123
+ `Git.open`, `Git.clone`, or `Git.init`, the user can invoke these methods to interact
124
+ with the underlying Git repository.
125
+
126
+ For example, the `git add` command is implemented as `Git::Base#add`, and the `git
127
+ ls-files` command is implemented as `Git::Base#ls_files`.
128
+
129
+ When a single Git command serves multiple distinct purposes, method names within the
130
+ `Git::Base` class should use the `git` command name as a prefix, followed by a
131
+ descriptive suffix to indicate the specific function.
132
+
133
+ For instance, `#ls_files_untracked` and `#ls_files_staged` could be used to execute
134
+ the `git ls-files` command and return untracked and staged files, respectively.
135
+
136
+ To enhance usability, aliases may be introduced to provide more user-friendly method
137
+ names where appropriate.
138
+
139
+ ### Parameter naming
60
140
 
61
- During the review process, you may need to make additional commits which would
62
- need to be squashed. It may also be necessary to rebase to master again if other
63
- changes are merged before your PR.
141
+ Parameters within the `git` gem methods are named after their corresponding long
142
+ command-line options, ensuring familiarity and ease of use for developers already
143
+ accustomed to Git. Note that not all Git command options are supported.
64
144
 
65
- At least one approval is required from a project maintainer before your pull
66
- request can be merged. The maintainer is responsible for ensuring that the pull
67
- request meets [the project's coding standards](#coding-standards).
145
+ ### Output processing
146
+
147
+ The `git` gem translates the output of many Git commands into Ruby objects, making it
148
+ easier to work with programmatically.
149
+
150
+ These Ruby objects often include methods that allow for further Git operations where
151
+ useful, providing additional functionality while staying true to the underlying Git
152
+ behavior.
68
153
 
69
154
  ## Coding standards
70
155
 
71
- In order to ensure high quality, all pull requests must meet these requirements:
156
+ To ensure high-quality contributions, all pull requests must meet the following
157
+ requirements:
158
+
159
+ ### Commit message guidelines
160
+
161
+ To enhance our development workflow, enable automated changelog generation, and pave
162
+ the way for Continuous Delivery, the `ruby-git` project has adopted the [Conventional
163
+ Commits standard](https://www.conventionalcommits.org/en/v1.0.0/) for all commit
164
+ messages.
165
+
166
+ This structured approach to commit messages allows us to:
167
+
168
+ - **Automate versioning and releases:** Tools can now automatically determine the
169
+ semantic version bump (patch, minor, major) based on the types of commits merged.
170
+ - **Generate accurate changelogs:** We can automatically create and update a
171
+ `CHANGELOG.md` file, providing a clear history of changes for users and
172
+ contributors.
173
+ - **Improve commit history readability:** A standardized format makes it easier for
174
+ everyone to understand the nature of changes at a glance.
175
+
176
+ #### What does this mean for contributors?
177
+
178
+ Going forward, all commits to this repository **MUST** adhere to the [Conventional
179
+ Commits standard](https://www.conventionalcommits.org/en/v1.0.0/). Commits not
180
+ adhering to this standard will cause the CI build to fail. PRs will not be merged if
181
+ they include non-conventional commits.
182
+
183
+ A git pre-commit hook may be installed to validate your conventional commit messages
184
+ before pushing them to GitHub by running `bin/setup` in the project root.
185
+
186
+ #### What to know about Conventional Commits
187
+
188
+ The simplist conventional commit is in the form `type: description` where `type`
189
+ indicates the type of change and `description` is your usual commit message (with
190
+ some limitations).
191
+
192
+ - Types include: `feat`, `fix`, `docs`, `test`, `refactor`, and `chore`. See the full
193
+ list of types supported in [.commitlintrc.yml](.commitlintrc.yml).
194
+ - The description must (1) not start with an upper case letter, (2) be no more than
195
+ 100 characters, and (3) not end with punctuation.
196
+
197
+ Examples of valid commits:
198
+
199
+ - `feat: add the --merges option to Git::Lib.log`
200
+ - `fix: exception thrown by Git::Lib.log when repo has no commits`
201
+ - `docs: add conventional commit announcement to README.md`
202
+
203
+ Commits that include breaking changes must include an exclaimation mark before the
204
+ colon:
205
+
206
+ - `feat!: removed Git::Base.commit_force`
207
+
208
+ The commit messages will drive how the version is incremented for each release:
209
+
210
+ - a release containing a **breaking change** will do a **major** version increment
211
+ - a release containing a **new feature** will do a **minor** increment
212
+ - a release containing **neither a breaking change nor a new feature** will do a
213
+ **patch** version increment
72
214
 
73
- ### 1 PR = 1 Commit
74
- * All commits for a PR must be squashed into one commit
75
- * To avoid an extra merge commit, the PR must be able to be merged as [a fast forward merge](https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging)
76
- * The easiest way to ensure a fast forward merge is to rebase your local branch
77
- to the ruby-git master branch
215
+ The full conventional commit format is:
216
+
217
+ ```text
218
+ <type>[optional scope][!]: <description>
219
+
220
+ [optional body]
221
+
222
+ [optional footer(s)]
223
+ ```
224
+
225
+ - `optional body` may include multiple lines of descriptive text limited to 100 chars
226
+ each
227
+ - `optional footers` only uses `BREAKING CHANGE: <description>` where description
228
+ should describe the nature of the backward incompatibility.
229
+
230
+ Use of the `BREAKING CHANGE:` footer flags a backward incompatible change even if it
231
+ is not flagged with an exclaimation mark after the `type`. Other footers are allowed
232
+ by not acted upon.
233
+
234
+ See [the Conventional Commits
235
+ specification](https://www.conventionalcommits.org/en/v1.0.0/) for more details.
78
236
 
79
237
  ### Unit tests
80
- * All changes must be accompanied by new or modified unit tests
81
- * The entire test suite must pass when `bundle exec rake default` is run from the
82
- project's local working copy.
83
238
 
84
- While working on specific features you can run individual test files or
85
- a group of tests using `bin/test`:
239
+ - All changes must be accompanied by new or modified unit tests.
240
+ - The entire test suite must pass when `bundle exec rake default` is run from the
241
+ project's local working copy.
242
+
243
+ While working on specific features, you can run individual test files or a group of
244
+ tests using `bin/test`:
245
+
246
+ ```bash
247
+ # run a single file (from tests/units):
248
+ $ bin/test test_object
86
249
 
87
- # run a single file (from tests/units):
88
- $ bin/test test_object
250
+ # run multiple files:
251
+ $ bin/test test_object test_archive
89
252
 
90
- # run multiple files:
91
- $ bin/test test_object test_archive
253
+ # run all unit tests:
254
+ $ bin/test
92
255
 
93
- # run all unit tests:
94
- $ bin/test
256
+ # run unit tests with a different version of the git command line:
257
+ $ GIT_PATH=/Users/james/Downloads/git-2.30.2/bin-wrappers bin/test
258
+ ```
95
259
 
96
260
  ### Continuous integration
97
- * All tests must pass in the project's [GitHub Continuous Integration build](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI)
98
- before the pull request will be merged.
99
- * The [Continuous Integration workflow](https://github.com/ruby-git/ruby-git/blob/master/.github/workflows/continuous_integration.yml)
100
- 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).
261
+
262
+ All tests must pass in the project's [GitHub Continuous Integration
263
+ build](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI) before the
264
+ pull request will be merged.
265
+
266
+ The [Continuous Integration
267
+ workflow](https://github.com/ruby-git/ruby-git/blob/master/.github/workflows/continuous_integration.yml)
268
+ runs both `bundle exec rake default` and `bundle exec rake test:gem` from the
269
+ project's [Rakefile](https://github.com/ruby-git/ruby-git/blob/master/Rakefile).
101
270
 
102
271
  ### Documentation
103
- * New and updated public methods must have [YARD](https://yardoc.org/)
104
- documentation added to them
105
- * New and updated public facing features should be documented in the project's
106
- [README.md](README.md)
107
272
 
108
- ### Licensing sign-off
109
- * Each commit must contain [the DCO sign-off](#developer-certificate-of-origin-dco)
110
- in the form: `Signed-off-by: Name <email>`
273
+ New and updated public methods must include [YARD](https://yardoc.org/)
274
+ documentation.
111
275
 
112
- ## Licensing
276
+ New and updated public-facing features should be documented in the project's
277
+ [README.md](README.md).
113
278
 
114
- ruby-git uses [the MIT license](https://choosealicense.com/licenses/mit/) as
115
- declared in the [LICENSE](LICENSE) file.
279
+ ## Building a specific version of the Git command-line
116
280
 
117
- Licensing is very important to open source projects. It helps ensure the
118
- software continues to be available under the terms that the author desired.
281
+ To test with a specific version of the Git command-line, you may need to build that
282
+ version from source code. The following instructions are adapted from Atlassian’s
283
+ [How to install Git](https://www.atlassian.com/git/tutorials/install-git) page for
284
+ building Git on macOS.
119
285
 
120
- ### Developer Certificate of Origin (DCO)
286
+ ### Install pre-requisites
121
287
 
122
- This project requires that authors have permission to submit their contributions
123
- under the MIT license. To make a good faith effort to ensure this, ruby-git
124
- requires the [Developer Certificate of Origin (DCO)](https://elinux.org/Developer_Certificate_Of_Origin)
125
- process be followed.
288
+ Prerequisites only need to be installed if they are not already present.
126
289
 
127
- This process requires that each commit include a `Signed-off-by` line that
128
- indicates the author accepts the DCO. Here is an example DCO sign-off line:
290
+ From your terminal, install Xcode’s Command Line Tools:
129
291
 
292
+ ```shell
293
+ xcode-select --install
130
294
  ```
131
- Signed-off-by: John Doe <john.doe@hisdomain.com>
295
+
296
+ Install [Homebrew](http://brew.sh/) by following the instructions on the Homebrew
297
+ page.
298
+
299
+ Using Homebrew, install OpenSSL:
300
+
301
+ ```shell
302
+ brew install openssl
132
303
  ```
133
304
 
134
- The full text of the DCO version 1.1 is below or at <http://developercertificate.org/>.
305
+ ### Obtain Git source code
306
+
307
+ Download and extract the source tarball for the desired Git version from [this source
308
+ code mirror](https://mirrors.edge.kernel.org/pub/software/scm/git/).
135
309
 
310
+ ### Build git
311
+
312
+ From your terminal, change to the root directory of the extracted source code and run
313
+ the build with following command:
314
+
315
+ ```shell
316
+ NO_GETTEXT=1 make CFLAGS="-I/usr/local/opt/openssl/include" LDFLAGS="-L/usr/local/opt/openssl/lib"
136
317
  ```
137
- Developer's Certificate of Origin 1.1
138
-
139
- By making a contribution to this project, I certify that:
140
-
141
- (a) The contribution was created in whole or in part by me and I
142
- have the right to submit it under the open source license
143
- indicated in the file; or
144
-
145
- (b) The contribution is based upon previous work that, to the
146
- best of my knowledge, is covered under an appropriate open
147
- source license and I have the right under that license to
148
- submit that work with modifications, whether created in whole
149
- or in part by me, under the same open source license (unless
150
- I am permitted to submit under a different license), as
151
- Indicated in the file; or
152
-
153
- (c) The contribution was provided directly to me by some other
154
- person who certified (a), (b) or (c) and I have not modified
155
- it.
156
-
157
- (d) I understand and agree that this project and the contribution
158
- are public and that a record of the contribution (including
159
- all personal information I submit with it, including my
160
- sign-off) is maintained indefinitely and may be redistributed
161
- consistent with this project or the open source license(s)
162
- involved.
318
+
319
+ The build script will place the newly compiled Git executables in the `bin-wrappers`
320
+ directory (e.g., `bin-wrappers/git`).
321
+
322
+ ### Use the new Git version
323
+
324
+ To configure programs that use the Git gem to utilize the newly built version, do the
325
+ following:
326
+
327
+ ```ruby
328
+ require 'git'
329
+
330
+ # Set the binary path
331
+ Git.configure { |c| c.binary_path = '/Users/james/Downloads/git-2.30.2/bin-wrappers/git' }
332
+
333
+ # Validate the version (if desired)
334
+ assert_equal([2, 30, 2], Git.binary_version)
163
335
  ```
336
+
337
+ Tests can be run using the newly built Git version as follows:
338
+
339
+ ```shell
340
+ GIT_PATH=/Users/james/Downloads/git-2.30.2/bin-wrappers bin/test
341
+ ```
342
+
343
+ Note: `GIT_PATH` refers to the directory containing the `git` executable.
344
+
345
+ ## Licensing
346
+
347
+ `ruby-git` uses [the MIT license](https://choosealicense.com/licenses/mit/) as
348
+ declared in the [LICENSE](LICENSE) file.
349
+
350
+ Licensing is critical to open-source projects as it ensures the software remains
351
+ available under the terms desired by the author.