Skip to content

Commit 2d6157c

Browse files
committed
Document this gem's (aspirational) design philosophy
1 parent d4f66ab commit 2d6157c

File tree

1 file changed

+135
-60
lines changed

1 file changed

+135
-60
lines changed

CONTRIBUTING.md

Lines changed: 135 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,116 +3,191 @@
33
# @title How To Contribute
44
-->
55

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+
* [How to contribute](#how-to-contribute)
7+
* [How to report an issue or request a feature](#how-to-report-an-issue-or-request-a-feature)
8+
* [How to submit a code or documentation change](#how-to-submit-a-code-or-documentation-change)
9+
* [Commit your changes to a fork of `ruby-git`](#commit-your-changes-to-a-fork-of-ruby-git)
10+
* [Create a pull request](#create-a-pull-request)
11+
* [Get your pull request reviewed](#get-your-pull-request-reviewed)
12+
* [Design philosophy](#design-philosophy)
13+
* [Direct mapping to git commands](#direct-mapping-to-git-commands)
14+
* [Parameter naming](#parameter-naming)
15+
* [Output processing](#output-processing)
16+
* [Coding standards](#coding-standards)
17+
* [1 PR = 1 Commit](#1-pr--1-commit)
18+
* [Unit tests](#unit-tests)
19+
* [Continuous integration](#continuous-integration)
20+
* [Documentation](#documentation)
21+
* [Licensing](#licensing)
22+
23+
24+
# Contributing to the git gem
25+
26+
Thank you for your interest in contributing to the `ruby-git` project.
27+
28+
This document provides guidelines for contributing to the `ruby-git` project. While
29+
these guidelines may not cover every situation, we encourage you to use your best
30+
judgment when contributing.
31+
32+
If you have suggestions for improving these guidelines, please propose changes via a
33+
pull request.
1534

1635
## How to contribute
1736

18-
You can contribute in two ways:
37+
You can contribute in the following ways:
1938

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)
39+
1. [Report an issue or request a
40+
feature](#how-to-report-an-issue-or-request-a-feature)
41+
2. [Submit a code or documentation
42+
change](#how-to-submit-a-code-or-documentation-change)
2243

23-
## How to report an issue or make a feature request
44+
## How to report an issue or request a feature
2445

25-
ruby-git utilizes [GitHub Issues](https://help.github.com/en/github/managing-your-work-on-github/about-issues)
46+
`ruby-git` utilizes [GitHub
47+
Issues](https://help.github.com/en/github/managing-your-work-on-github/about-issues)
2648
for issue tracking and feature requests.
2749

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.
50+
To report an issue or request a feature, please [create a `ruby-git` GitHub
51+
issue](https://github.com/ruby-git/ruby-git/issues/new). Fill in the template as
52+
thoroughly as possible to describe the issue or feature request.
3053

3154
## How to submit a code or documentation change
3255

33-
There is three step process for code or documentation changes:
56+
There is a three-step process for submitting code or documentation changes:
3457

35-
1. [Commit your changes to a fork of ruby-git](#commit-changes-to-a-fork-of-ruby-git)
58+
1. [Commit your changes to a fork of
59+
`ruby-git`](#commit-your-changes-to-a-fork-of-ruby-git)
3660
2. [Create a pull request](#create-a-pull-request)
3761
3. [Get your pull request reviewed](#get-your-pull-request-reviewed)
3862

39-
### Commit changes to a fork of ruby-git
63+
### Commit your changes to a fork of `ruby-git`
4064

41-
Make your changes in a fork of the ruby-git repository.
65+
Make your changes in a fork of the `ruby-git` repository.
4266

4367
### Create a pull request
4468

45-
See [this article](https://help.github.com/articles/about-pull-requests/) if you
46-
are not familiar with GitHub Pull Requests.
69+
If you are not familiar with GitHub Pull Requests, please refer to [this
70+
article](https://help.github.com/articles/about-pull-requests/).
4771

4872
Follow the instructions in the pull request template.
4973

5074
### Get your pull request reviewed
5175

52-
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).
76+
Code review takes place in a GitHub pull request using the [GitHub pull request
77+
review
78+
feature](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-reviews).
5379

5480
Once your pull request is ready for review, request a review from at least one
55-
[maintainer](MAINTAINERS.md) and any number of other contributors.
81+
[maintainer](MAINTAINERS.md) and any other contributors you deem necessary.
82+
83+
During the review process, you may need to make additional commits, which should be
84+
squashed. Additionally, you may need to rebase your branch to the latest `master`
85+
branch if other changes have been merged.
86+
87+
At least one approval from a project maintainer is required before your pull request
88+
can be merged. The maintainer is responsible for ensuring that the pull request meets
89+
[the project's coding standards](#coding-standards).
90+
91+
## Design philosophy
92+
93+
*Note: As of v2.x of the `git` gem, this design philosophy is aspirational. Future
94+
versions may include interface changes to fully align with these principles.*
95+
96+
The `git` gem is designed as a lightweight wrapper around the `git` command-line
97+
tool, providing Ruby developers with a simple and intuitive interface for
98+
programmatically interacting with Git.
99+
100+
This gem adheres to the "principle of least surprise," ensuring that it does not
101+
introduce unnecessary abstraction layers or modify Git's core functionality. Instead,
102+
the gem maintains a close alignment with the existing `git` command-line interface,
103+
avoiding extensions or alterations that could lead to unexpected behaviors.
104+
105+
By following this philosophy, the `git` gem allows users to leverage their existing
106+
knowledge of Git while benefiting from the expressiveness and power of Ruby's syntax
107+
and paradigms.
108+
109+
### Direct mapping to git commands
56110

57-
During the review process, you may need to make additional commits which would
58-
need to be squashed. It may also be necessary to rebase to master again if other
59-
changes are merged before your PR.
111+
Git commands are implemented within the `Git::Base` class, with each method directly
112+
corresponding to a `git` command. When a `Git::Base` object is instantiated via
113+
`Git.open`, `Git.clone`, or `Git.init`, the user can invoke these methods to interact
114+
with the underlying Git repository.
60115

61-
At least one approval is required from a project maintainer before your pull
62-
request can be merged. The maintainer is responsible for ensuring that the pull
63-
request meets [the project's coding standards](#coding-standards).
116+
For example, the `git add` command is implemented as `Git::Base#add`, and the `git
117+
ls-files` command is implemented as `Git::Base#ls_files`.
118+
119+
When a single Git command serves multiple distinct purposes, method names within the
120+
`Git::Base` class should use the `git` command name as a prefix, followed by a
121+
descriptive suffix to indicate the specific function.
122+
123+
For instance, `#ls_files_untracked` and `#ls_files_staged` could be used to execute
124+
the `git ls-files` command and return untracked and staged files, respectively.
125+
126+
To enhance usability, aliases may be introduced to provide more user-friendly method
127+
names where appropriate.
128+
129+
### Parameter naming
130+
131+
Parameters within the `git` gem methods are named after their corresponding long
132+
command-line options, ensuring familiarity and ease of use for developers already
133+
accustomed to Git. Note that not all Git command options are supported.
134+
135+
### Output processing
136+
137+
The `git` gem translates the output of many Git commands into Ruby objects, making it
138+
easier to work with programmatically.
139+
140+
These Ruby objects often include methods that allow for further Git operations where
141+
useful, providing additional functionality while staying true to the underlying Git
142+
behavior.
64143

65144
## Coding standards
66145

67-
In order to ensure high quality, all pull requests must meet these requirements:
146+
To ensure high-quality contributions, all pull requests must meet the following
147+
requirements:
68148

69149
### 1 PR = 1 Commit
70150

71-
* All commits for a PR must be squashed into one commit
72-
* To avoid an extra merge commit, the PR must be able to be merged as [a fast forward
73-
merge](https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging)
74-
* The easiest way to ensure a fast forward merge is to rebase your local branch to
75-
the ruby-git master branch
151+
* All commits for a PR must be squashed into a single commit.
152+
* To avoid an extra merge commit, the PR must be able to be merged as [a fast-forward
153+
merge](https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging).
154+
* The easiest way to ensure a fast-forward merge is to rebase your local branch to
155+
the `ruby-git` master branch.
76156

77157
### Unit tests
78158

79-
* All changes must be accompanied by new or modified unit tests
159+
* All changes must be accompanied by new or modified unit tests.
80160
* The entire test suite must pass when `bundle exec rake default` is run from the
81161
project's local working copy.
82162

83-
While working on specific features you can run individual test files or
84-
a group of tests using `bin/test`:
163+
While working on specific features, you can run individual test files or a group of
164+
tests using `bin/test`:
85165

86-
# run a single file (from tests/units):
87-
$ bin/test test_object
166+
```bash
167+
# run a single file (from tests/units):
168+
$ bin/test test_object
88169

89-
# run multiple files:
90-
$ bin/test test_object test_archive
170+
# run multiple files:
171+
$ bin/test test_object test_archive
91172

92-
# run all unit tests:
93-
$ bin/test
173+
# run all unit tests:
174+
$ bin/test
175+
```
94176

95177
### Continuous integration
96178

97-
* All tests must pass in the project's [GitHub Continuous Integration
98-
build](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI) before the
99-
pull request will be merged.
100-
* The [Continuous Integration
101-
workflow](https://github.com/ruby-git/ruby-git/blob/master/.github/workflows/continuous_integration.yml)
102-
runs both `bundle exec rake default` and `bundle exec rake test:gem` from the
103-
project's [Rakefile](https://github.com/ruby-git/ruby-git/blob/master/Rakefile).
179+
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.
180+
181+
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).
104182

105183
### Documentation
106184

107-
* New and updated public methods must have [YARD](https://yardoc.org/) documentation
108-
added to them
109-
* New and updated public facing features should be documented in the project's
110-
[README.md](README.md)
185+
New and updated public methods must include [YARD](https://yardoc.org/) documentation.
186+
187+
New and updated public-facing features should be documented in the project's [README.md](README.md).
111188

112189
## Licensing
113190

114-
ruby-git uses [the MIT license](https://choosealicense.com/licenses/mit/) as
115-
declared in the [LICENSE](LICENSE) file.
191+
`ruby-git` uses [the MIT license](https://choosealicense.com/licenses/mit/) as declared in the [LICENSE](LICENSE) file.
116192

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.
193+
Licensing is critical to open-source projects as it ensures the software remains available under the terms desired by the author.

0 commit comments

Comments
 (0)