Skip to content

Commit b3bc056

Browse files
committed
Expand contribution guidelines, for larger changes.
1 parent b20a23e commit b3bc056

File tree

1 file changed

+99
-14
lines changed

1 file changed

+99
-14
lines changed

CONTRIBUTING.md

Lines changed: 99 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@ and agree by submitting the patch
77
that your contributions are licensed under
88
the [Swift license](https://swift.org/LICENSE.txt).
99

10-
For now,
11-
we’re expecting most pull requests to be enhancements and bug fixes
12-
to support the Swift-DocC publication,
13-
with only minor content changes.
14-
1510
For small changes,
16-
like typo fixes and changes to a few paragraphs,
17-
fork this repository and make a pull request.
18-
19-
A formal contribution process for this document is still in development.
20-
In the meantime,
21-
start a thread in the [Swift forums][forum] for larger changes
11+
like typo fixes and revisions within a few paragraphs,
12+
the discussion of those changes is usually small enough
13+
to be part of the pull request.
14+
For large changes,
15+
like new chapters and sections,
16+
start a thread in the [Swift forums][forum]
2217
to discuss your approach and identify possible issues
2318
before you invest a lot of time in writing.
19+
In general,
20+
the amount of discussion around a change before making a pull request
21+
corresponds to the size of that change.
2422

2523
Content in this book follows [Apple Style Guide][asg]
2624
and [this book’s style guide][tspl-style].
@@ -29,13 +27,100 @@ and [this book’s style guide][tspl-style].
2927
[forum]: https://forums.swift.org/c/development/swift-docc/80
3028
[tspl-style]: /Style.md
3129

30+
## Creating a feature branch
31+
32+
If this is your first contribution,
33+
start by making a fork of the Git repository.
34+
35+
In your fork,
36+
make a new branch off of `main`.
37+
Some suggested branch-naming practices include the following:
38+
39+
- Include numbers like a GitHub issue or Swift Evolution proposal number,
40+
to make it easy to go back from the branch to that issue or SE proposal.
41+
However, put the numbers at the end of the branch name,
42+
to avoid interfering with autocompletion.
43+
You're more likely to remember the English word the branch name starts with
44+
than to remember the numbers.
45+
46+
- Prefer underscores (`_`) between words instead of hyphens (`-`).
47+
Many editing environments consider hyphens to be word separators,
48+
so using underscores makes makes it easier to select the branch name
49+
by double-clicking or another editor command to select a whole word.
50+
51+
- Avoid overly long branch names.
52+
You can usually describe what a branch is for in a few words.
53+
Remember that a branch name doesn't need to stand alone:
54+
the commits on that branch help explain its purpose,
55+
and during review the pull request provides more context.
56+
57+
Note that branch names are ephemeral:
58+
When your branch is merged,
59+
the merge commit includes information like
60+
the name of the pull request and its number,
61+
but not the name of the merged branch or the name of the fork.
62+
Make sure the branch name isn't the only place you write a piece of information.
63+
For example,
64+
when you fix a GitHub issue,
65+
include a "Fixes" line in the description of your pull request.
66+
67+
If you need to incorporate changes from `main` or resolve a merge conflict,
68+
merge that branch into your feature branch.
69+
Before creating a pull request,
70+
you can instead rebase your feature branch onto `main` if you prefer,
71+
but don't rebase commits that are part of a pull request.
72+
73+
## Writing commit messages
74+
75+
Use the Git commit message to communicate with other contributors --
76+
both the people working on the project now
77+
who are reviewing your changes,
78+
and the people who will join the project in the future
79+
and will need to understand your changes.
80+
Well-written commit messages make it possible
81+
to come back to content later using tools like `git-blame`,
82+
and find the reason why the content is written that way.
83+
84+
Every commit starts with a one-sentence summary.
85+
The summary usually fits in 50 characters,
86+
but it's ok to exceed that amount occasionally
87+
if rewriting for brevity would make it too hard to read.
88+
89+
If you can't explain the commit entirely in its summary,
90+
skip one line and add additional information.
91+
This additional information includes information like
92+
the reasons for the change,
93+
the approach you took when making it,
94+
alternatives you considered,
95+
and a summary of what you changed.
96+
Hard wrap these lines at 72 characters
97+
and leave a blank line between paragraphs.
98+
Remember that the body of a commit is plain text,
99+
not markdown like the content of the book.
100+
101+
Most text editors can help you write a commit message
102+
by marking lines that are too long
103+
and hard wrapping text automatically.
104+
32105
## Submitting a pull request
33106

34107
Use the following steps when creating a new pull request:
35108

36-
1. Create a local fork of this repository with your changes.
37-
2. Test that your changes build locally by running `make preview`.
38-
3. Create a pull request in this repository.
109+
1. Test that your changes build locally by running `make preview`.
110+
2. Create a pull request in this repository.
111+
3. Write a brief message in the pull request to introduce your work in context.
39112

40113
Within a few days,
41114
someone will assign reviewers and start a build in CI.
115+
116+
During the review of the pull request,
117+
add new commits on your branch to incorporate feedback,
118+
but don’t rebase or force push.
119+
Rewriting the branch's history
120+
makes it hard for reviewers to see
121+
what changed since the last time they reviewed your changes.
122+
If there are merge conflicts,
123+
merge `main` into your branch or use the GitHub web UI
124+
to resolve the conflicts when accepting the pull request.
125+
126+
After a pull request is merged, delete the feature branch.

0 commit comments

Comments
 (0)