Skip to content

Commit 0b4b37c

Browse files
committed
Updated contribution guide
1 parent c69fd36 commit 0b4b37c

File tree

3 files changed

+178
-83
lines changed

3 files changed

+178
-83
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ make install
9191
```
9292

9393

94+
## Contributing
95+
96+
We welcome all contributions to the OpenSCAP project. If you would like to contribute, either by fixing existing issues or adding new features, please check out our [contribution guide](docs/contribute/contribute.adoc) to get started. If you would like to discuss anything, ask questions, or if you need additional help getting started, you can either send a message to our FreeNode IRC channel, **#openscap**, or to our [mailing list](https://www.redhat.com/mailman/listinfo/open-scap-list).
97+
98+
9499
## Use cases
95100

96101
### SCAP Content Validation

docs/contribute/contribute.adoc

Lines changed: 114 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,126 +4,161 @@ This document is meant for new OpenSCAP contributors and it describes how to
44
contribute to the OpenSCAP project. Let's suppose that you already have an
55
active Github's account with a user name _adam_ and you want to fix one of the
66
issue from the link:https://github.com/OpenSCAP/openscap/issues[tracker]. Let's
7-
say that we want to fix the isuues with number _455_ and the fix will go into
8-
the _maint-1.0_ branch.
7+
say that you want to fix the issue with number _455_ and the fix will go into
8+
the `maint-1.2` branch.
99

10-
== Fork the OpenSCAP repository
10+
NOTE: This guide also applies for adding a new feature, the process is the same
11+
as for fixing an issue described below.
12+
13+
14+
== Fork and setup the OpenSCAP repository
1115
Before you start working on a fix it's a good practice to leave a
1216
comment in the issue that you work on the fix so other contributors know that
1317
the fix is in progress. Next thing you have to do is to fork the OpenSCAP
14-
repository. You can do that by pressing the **Fork** button in the top-right
18+
repository. You can do that by pressing the *'Fork'* button in the top-right
1519
corner on the Github's link:https://github.com/OpenSCAP/openscap[OpenSCAP page].
1620
It will create a copy of the original repository which you can use for
17-
proposing changes.
21+
proposing changes. Then you can clone your forked repository:
22+
[[app-listing]]
23+
[source,bash]
24+
----
25+
$ git clone [email protected]:adam/openscap.git
26+
----
27+
28+
Sometimes you will need to update your forked repository with the latest
29+
upstream changes. To be able to do so you need to add a remote (we will name it
30+
upstream) which will track the upstream OpenSCAP repository:
31+
[[app-listing]]
32+
[source,bash]
33+
----
34+
$ cd openscap/
35+
# add remote name 'upstream' to refer to the upstream's repository
36+
$ git remote add upstream [email protected]:OpenSCAP/openscap.git
37+
----
38+
39+
NOTE: In the code snippets, lines starting with # are comments and lines
40+
starting with $ are commands.
41+
1842

1943
== Choose the right branch
20-
Before you start working of the fix it's necessary to determine which branch the
44+
Before you start working on the fix it's necessary to determine which branch the
2145
fix will go into. If you are not familiar with the OpenSCAP's branches or
2246
versions yet please have a look at the link:versioning.adoc[versioning]
2347
document. Be aware that the fact that an issue description says that the fix
24-
should go to a _maint-1.2_ branch doesn't have to be true. It's a good practice
48+
should go to the `maint-1.2` branch doesn't have to be true. It's a good practice
2549
to investigate the correct branch first or ask experienced developers on our
2650
FreeNode IRC channel called `#openscap` or
2751
link:https://www.redhat.com/mailman/listinfo/open-scap-list[mailing list].
2852

29-
Once you have forked the repository and decided what branch the fix will go into
30-
you can clone your forked repository.
53+
NOTE: The default branch of the openscap repository is set to the `maint-1.2`.
54+
55+
Once you have forked the repository and decided that the fix will go into the
56+
`maint-1.2` branch you can create a new branch from it, which we will call
57+
_fix_455_, where you can work on the fix. Remember that the name of the new
58+
branch will appear in the commit message when your fix is merged so choose the
59+
name wisely:
60+
3161
[[app-listing]]
3262
[source,bash]
3363
----
34-
$ git clone [email protected]:adam/openscap.git
64+
$ git checkout maint-1.2
65+
# create a new branch
66+
$ git checkout -b fix_455
3567
----
3668

37-
38-
Now you can create a new branch, which we will call _fix_455_, where you can work on the fix. Remember that
39-
the name of the new branch will appear in the commit message when your fix is
40-
merged so choose the name wisely.
41-
69+
On the other hand, if you decided that the fix will go into the `master` branch
70+
you have to switch to this branch first before creating a new one:
4271
[[app-listing]]
4372
[source,bash]
4473
----
45-
# checkout to the maint-1.0 branch
46-
$ git checkout maint-1.0
47-
# create a new branch
74+
# create a new local branch to track the remote master branch
75+
$ git checkout -b master remotes/origin/master
76+
# and now create a new branch from the master branch which will contain your fix
4877
$ git checkout -b fix_455
4978
----
5079

51-
NOTE: The default branch of the openscap repository is set to the `maint-1.2`.
52-
Our fix will go into the `maint-1.0` so we have to switch to this branch before
53-
creating a new one.
5480

5581
== Fix the issue
56-
NOTE: OpenSCAP is licensed under LGPLv2. Any fixes or improvements must be licensed
57-
under the same license to be included. Check the COPYING file in the repository
58-
for more details.
82+
NOTE: OpenSCAP is licensed under _LGPL v2.1_. Any fixes or improvements must be
83+
licensed under the same license to be included. Check the COPYING file in the
84+
repository for more details.
5985

6086
Now you can work on the fix. Try to create small commits which can be easily
6187
reviewed and make self-explaining commit messages. The
6288
link:http://chris.beams.io/posts/git-commit/[How to Write a Git Commit
6389
Message] article could help you with that. Nobody will review a pull request
6490
which contains a four thousand new lines of code.
6591

66-
NOTE: Since we're fixing an issue number 455 make sure that your commit message
67-
contain a
92+
NOTE: Since you're fixing issue number 455 make sure that your commit
93+
message contain a
6894
link:https://help.github.com/articles/closing-issues-via-commit-messages/[keyword]
6995
which will close the issue automatically when your pull request is merged.
7096

71-
7297
Let's say that you've fixed the issue, made a few commits to your local fix_455
73-
branch and you think it's ready to be review by other contributors. Before you
98+
branch and you think it's ready to be reviewed by other contributors. Before you
7499
push your local changes to your remote forked repository it's necessary to check
75100
if your changes will be applicable and won't be in a conflict with some work that
76-
other contributors could publish while you were working on the fix.
101+
other contributors could have published while you were working on the fix.
77102

78103

79104
== Rebase before pull request
80-
If some other contributor pushed some code to the maint-1.0 branch while you was
81-
working of the fix then it's necessary to pull those changes and rebase our fix
82-
on top of them. First we need to make sure that our local maint-1.0 branch is
83-
up-to date.
105+
If some other contributor pushed some code to the `maint-1.2` branch while you
106+
were working on the fix and if there would be a conflict between your changes
107+
then it might be necessary to fetch those changes and rebase your fix on top
108+
of them. First you need to make sure that your local `maint-1.2` branch is
109+
up-to date:
84110

85111
[[app-listing]]
86112
[source,bash]
87113
----
88-
# add remote name 'upstream' to refer to the upstream's repository
89-
$ git remote add upstream [email protected]:OpenSCAP/openscap.git
90-
# checkout to branch 'maint-1.0' in your local forked repository
91-
$ git checkout maint-1.0
92-
# download and apply any upstream changes to your local maint-1.0 branch
93-
$ git pull --ff-only upstream maint-1.0
114+
# checkout to branch 'maint-1.2' in your local forked repository
115+
$ git checkout maint-1.2
116+
# download and apply any upstream changes to your local maint-1.2 branch
117+
$ git pull upstream maint-1.2
118+
# now you can optionally also push these changes to your fork on Github (recommended)
119+
$ git push origin maint-1.2
94120
----
95121

96122
Now you can go back to your local branch with the fix and try to rebase your
97-
changes on top of your local updated maint-1.0 branch. If there are no conflicts
98-
then you can push your branch with the fix to your remote forked repository.
123+
changes on top of your local updated `maint-1.2` branch:
99124

100125
[[app-listing]]
101126
[source,bash]
102127
----
103128
# checkout back to your branch with the fix
104129
$ git checkout fix_455
105-
# rebase your changes on the top of the updated maint-1.0 branch
106-
$ git rebase maint-1.0
107-
# push your changes to your remote forked repository
130+
# rebase your changes on the top of the updated maint-1.2 branch
131+
$ git rebase maint-1.2
132+
----
133+
134+
If there are no conflicts then you can push your branch with the fix to your
135+
remote forked repository:
136+
137+
[[app-listing]]
138+
[source,bash]
139+
----
140+
# push your changes to your remote forked repository (also see the note below)
108141
$ git push origin fix_455
109-
# note about --force
110142
----
111143

112-
NOTE: If you've already push the branch to your remote repository then made some
113-
changes and know you want to rewrite the fix_455 branch then the `--force`
114-
option may come in handy but be aware that it will rewrite your fix_455 branch
115-
so please use wisely.
144+
NOTE: The previous `git push` command will not work if you've already pushed the
145+
branch to your remote repository. If this is the case, but you made some new
146+
changes/updates and you want to push them into the fix_455 branch then append
147+
the `--force` after the `git push` command. Be aware that it will rewrite your
148+
fix_455 branch in your remote forked repository.
149+
116150

117151
== Create a new pull request
118152
Once you have pushed your local fix_455 branch to your remote forked repository
119153
you can link:https://help.github.com/articles/creating-a-pull-request/[create] a
120154
new pull request. You can create the pull request on the OpenSCAP's
121155
link:https://github.com/OpenSCAP/openscap/pulls[github page] when you click on
122-
the `Pull requests` in the right menu then you see the green *New pull request*
123-
button. In the branch menu choose the branch that contains your fix. That is the
124-
fix_455 branch and also don't forget to set maint-1.0 as the base branch. The
125-
base branch is the one that your fix_455 will be compared to. If there are no
126-
conflicts add some description and hit the *Create pull request* button.
156+
the *'Pull requests'* in the right menu then you see the green
157+
*'New pull request'* button. In the branch menu choose the branch that contains
158+
your fix. That is the fix_455 branch and also don't forget to set `maint-1.2`
159+
as the base branch. The base branch is the one that your fix_455 will be
160+
compared to. If there are no conflicts add some description and hit the
161+
*'Create pull request'* button.
127162

128163
Developers and contributor that watch the repository should now
129164
receive an email about a new pull request. They will review your code and
@@ -135,40 +170,53 @@ After the review is done and one or more experienced developers is complaining
135170
about your code you have to do some changes. There are two ways to change your
136171
code in a submitted pull request:
137172

138-
. Add a new commit or,
139-
. edit existing commits.
173+
. Add a new commit,
174+
. or edit existing commits.
140175

141176
==== Add a new commit
142-
Adding a new commit is easy and I would choose this option if I would have to
143-
add something new like a function or a new module.
177+
Adding a new commit is easy and it is a good option if you have to add something
178+
new like a function or a new module.
144179

145180
==== Edit existing commits
146-
If you just need to fix a typo or add a condition I would choose to go back to
147-
the commit, where the change is needed, and use commit's `--ammed` option to
148-
change the commit. You can use following steps to do that.
181+
If you just need to fix something (for example a typo) you need to go back to
182+
the commit where the change is needed and use commit's `--amend` option to
183+
change the commit. You can use the following steps to do that:
149184

150185
[[app-listing]]
151186
[source,bash]
152187
----
153188
# show all the commits in your fix_455 branch
154-
$ git rebase -i maint-1.0
155-
# replace 'pick' with 'e' at a line with commit you'd like to change
189+
$ git rebase -i maint-1.2
190+
# replace 'pick' with 'e' at the line with commit(s) you'd like to edit
156191
# make your changes
157192
# vim my_source_file.c
158193
# commit your new changes
159194
$ git commit --amend
160-
# get back to your last commit
195+
# move to the next commit which you selected for editing using 'e' in the
196+
# 'git rebase' command
161197
$ git rebase --continue
162198
----
163199

200+
When you are finished with editing commits you can force push all the changes
201+
into your remote repository to update it with your latest edits. The pull
202+
request will be updated automatically too:
203+
204+
[[app-listing]]
205+
[source,bash]
206+
----
207+
$ git push --force origin fix_455
208+
----
209+
164210
=== Closing the pull request
165211
Once the pull request has been merged to upstream's branch the pull request will
166212
be closed automatically. The issue will be also closed if you used the right
167-
keyword in the commit message. Now you can delete your `fix_455` branch.
213+
keyword in the commit message. Now you can delete your `fix_455` branch:
168214

169215
[[app-listing]]
170216
[source,bash]
171217
----
172-
# detele the fix_455 branch
218+
# detele the fix_455 branch locally
173219
$ git branch -d fix_455
220+
# optionally also delete the fix_455 branch from your remote forked repository
221+
$ git push origin --delete fix_455
174222
----

0 commit comments

Comments
 (0)