Skip to content

Commit a438f4d

Browse files
committed
Add initial set of contribution guidelines
This change documents some of the steps required in order to contribute to `Net::HTTP` in the hope that it helps newcomers to the project create their first submission(s) and is submitted in response to a discussion in libwww-perl#76. It includes a quick start guide for setting up a `perlbrew` environment as well as how to install `Dist::Zilla` and how to use it to install upstream dependencies. The document also describes the steps necessary to create a pull request from a feature branch in a user's forked repository.
1 parent 91e091b commit a438f4d

File tree

1 file changed

+214
-0
lines changed

1 file changed

+214
-0
lines changed

CONTRIBUTING.md

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
# How to contribute to Net::HTTP
2+
3+
Many thanks for taking the time to contribute!
4+
5+
These are some guidelines intended to help you contribute to `Net::HTTP`.
6+
7+
In general, if you want to submit code and/or documentation changes, first
8+
[fork the
9+
project](https://docs.github.com/en/get-started/quickstart/fork-a-repo) and
10+
provide your contribution as a [pull
11+
request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).
12+
13+
## Setting up the development environment
14+
15+
It is recommended that you install [perlbrew](https://perlbrew.pl/) and so
16+
that your Perl distribution and any modules you install are local to your
17+
user account and hence don't conflict with any system-wide programs and
18+
modules which may already be on your computer.
19+
20+
### perlbrew quick start guide
21+
22+
Assuming a Linux-like environment and the `bash` shell, here is how to get
23+
your `perlbrew` environment up and running quickly.
24+
25+
Install `perlbrew` by running the following command:
26+
27+
```
28+
\curl -L https://install.perlbrew.pl | bash
29+
```
30+
31+
Add the `perlbrew` environment setup script to your shell's startup files so
32+
that `perlbrew` is available each time you start a shell:
33+
34+
```
35+
echo 'source ~/perl5/perlbrew/etc/bashrc' >> ~/.profile
36+
```
37+
38+
To initialise the `perlbrew` environment directly, run:
39+
40+
```
41+
source ~/perl5/perlbrew/etc/bashrc
42+
```
43+
44+
Ensure that you install
45+
[`cpanm`](https://metacpan.org/dist/App-cpanminus/view/bin/cpanm) to make
46+
module installation easier:
47+
48+
```
49+
perlbrew install-cpanm
50+
```
51+
52+
Now you can install your very on local Perl version. To see which Perl
53+
versions use the `available` subcommand:
54+
55+
```
56+
perlbrew available
57+
```
58+
59+
To install a given Perl version specify the version when invoking the
60+
`install` subcommand, e.g.:
61+
62+
```
63+
perlbrew install 5.34.1
64+
```
65+
66+
It will take several minutes for Perl to build, test and be installed.
67+
68+
Now you can `switch` permanently to your new Perl version:
69+
70+
```
71+
perlbrew switch 5.34.1
72+
```
73+
74+
### Installing `Dist::Zilla`
75+
76+
[`Dist::Zilla`](https://metacpan.org/pod/Dist::Zilla) is a distribution
77+
builder and is used in this project to handle upstream module dependencies
78+
as well as run the test suite. To install `Dist::Zilla` run:
79+
80+
```
81+
cpanm --notest Dist::Zilla
82+
```
83+
84+
You should now find that the `dzil` command is available, e.g.:
85+
86+
```
87+
dzil --help
88+
```
89+
90+
## Building and testing the distribution
91+
92+
Clone your fork of the repository to your local development environment and
93+
change into the directory this creates:
94+
95+
```
96+
git clone [email protected]:<username>/Net-HTTP.git
97+
cd Net-HTTP
98+
```
99+
100+
Now install any dependencies that are missing from your local Perl
101+
installation with the `dzil` command:
102+
103+
```
104+
dzil authordeps --missing | cpanm
105+
dzil listdeps --missing | cpanm
106+
```
107+
108+
To run the test suite use `dzil test`:
109+
110+
```
111+
dzil test
112+
```
113+
114+
If you see the message at the end of the output similar to this:
115+
116+
```
117+
All tests successful.
118+
Files=6, Tests=29, 1 wallclock secs ( 0.07 usr 0.02 sys + 0.85 cusr 0.11 csys = 1.05 CPU)
119+
Result: PASS
120+
```
121+
122+
then the test suite has passed and you've now got a good foundation upon
123+
which you can base your contribution.
124+
125+
## Contributing a change to the code and/or documentation
126+
127+
Code and documentation contributions are prepared on branches which are
128+
pushed to your remote fork on GitHub (also known by the name `origin`) and
129+
are submitted as pull requests. A good pull request will focus on specific
130+
topic such as a fix for a particular bug or an typo fix in the
131+
documentation. Please do not submit pull requests which mix different kinds
132+
of changes together. In other words don't submit a bug fix which also fixes
133+
an unrelated typo in a comment and reformats a separate part of the code:
134+
these should be submitted in separate pull requests.
135+
136+
### Call the upstream repository 'upstream'
137+
138+
When keeping your local repository up to date with the state of the upstream
139+
project's remote repository, it is useful to refer to it as simply
140+
`upstream`. Note that you only need to do this step the once: you do not
141+
need to do this for each contribution. To give the remote repository of the
142+
upstream project the name `upstream` use the following `git` command:
143+
144+
```
145+
git remote add upstream [email protected]:libwww-perl/Net-HTTP.git
146+
```
147+
148+
### Update local `master` branch with `upstream`'s `master` branch
149+
150+
Before working on a contribution it is important that you have the most up
151+
to date state of the `upstream` project's `master` branch. First fetch the
152+
state of the `upstream` `master` branch, and then merge this into your local
153+
`master` branch so that your local repository is completely up to date:
154+
155+
```
156+
git fetch upstream master
157+
git merge upstream/master
158+
```
159+
160+
### Create an appropriately-named branch
161+
162+
Using a good name for your branch makes it much easier to refer to
163+
contribution. Suppose you provide a fix for the [issue that using HTTP proxy
164+
hangs](https://github.com/libwww-perl/Net-HTTP/issues/25); you could name
165+
your branch something like `http-proxy-hang-fix`. To create a branch with
166+
this name and immediately switch to the new branch, use `git checkout` with
167+
the `-b` option:
168+
169+
```
170+
git checkout -b http-proxy-hang-fix
171+
```
172+
173+
### Make the change
174+
175+
Now that you have checked out your feature branch, you're ready to implement
176+
your fix (or whatever change you wish to contribute). Now comes the fun
177+
part: hacking the code! Commit your changes and prepare your branch for
178+
submission.
179+
180+
### Ensure the test suite passes
181+
182+
Before submitting any change, please ensure that the test suite still
183+
passes:
184+
185+
```
186+
dzil test
187+
```
188+
189+
### Push your branch to your repository's origin
190+
191+
If you're satisfied with the code changes and the test suite still passes,
192+
you can push your changes on your feature branch to your remote fork on
193+
GitHub (also known by the name `origin`):
194+
195+
```
196+
git push
197+
```
198+
199+
### Create a pull request
200+
201+
Now you're ready to create a [pull
202+
request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork)
203+
to submit your proposed changes. Using the GitHub web interface, prepare a
204+
pull request which compares the changes in your fork's feature branch with
205+
the `master` branch of the main project.
206+
207+
Please provide a concise yet descriptive title for the change you are
208+
proposing. Also provide a full description of the changes in your pull
209+
request within the description field and why these changes solve a
210+
particular problem as well as any background information which might be
211+
relevant.
212+
213+
As soon as you're ready, click on the "Create pull request" button to submit
214+
your pull request, and you're done! Many thanks for your contribution!

0 commit comments

Comments
 (0)