@@ -4,126 +4,161 @@ This document is meant for new OpenSCAP contributors and it describes how to
4
4
contribute to the OpenSCAP project. Let's suppose that you already have an
5
5
active Github's account with a user name _adam_ and you want to fix one of the
6
6
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.
9
9
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
11
15
Before you start working on a fix it's a good practice to leave a
12
16
comment in the issue that you work on the fix so other contributors know that
13
17
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
15
19
corner on the Github's link:https://github.com/OpenSCAP/openscap[OpenSCAP page].
16
20
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
+
18
42
19
43
== 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
21
45
fix will go into. If you are not familiar with the OpenSCAP's branches or
22
46
versions yet please have a look at the link:versioning.adoc[versioning]
23
47
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
25
49
to investigate the correct branch first or ask experienced developers on our
26
50
FreeNode IRC channel called `#openscap` or
27
51
link:https://www.redhat.com/mailman/listinfo/open-scap-list[mailing list].
28
52
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
+
31
61
[[app-listing]]
32
62
[source,bash]
33
63
----
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
35
67
----
36
68
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:
42
71
[[app-listing]]
43
72
[source,bash]
44
73
----
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
48
77
$ git checkout -b fix_455
49
78
----
50
79
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.
54
80
55
81
== 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.
59
85
60
86
Now you can work on the fix. Try to create small commits which can be easily
61
87
reviewed and make self-explaining commit messages. The
62
88
link:http://chris.beams.io/posts/git-commit/[How to Write a Git Commit
63
89
Message] article could help you with that. Nobody will review a pull request
64
90
which contains a four thousand new lines of code.
65
91
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
68
94
link:https://help.github.com/articles/closing-issues-via-commit-messages/[keyword]
69
95
which will close the issue automatically when your pull request is merged.
70
96
71
-
72
97
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
74
99
push your local changes to your remote forked repository it's necessary to check
75
100
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.
77
102
78
103
79
104
== 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:
84
110
85
111
[[app-listing]]
86
112
[source,bash]
87
113
----
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
94
120
----
95
121
96
122
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:
99
124
100
125
[[app-listing]]
101
126
[source,bash]
102
127
----
103
128
# checkout back to your branch with the fix
104
129
$ 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)
108
141
$ git push origin fix_455
109
- # note about --force
110
142
----
111
143
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
+
116
150
117
151
== Create a new pull request
118
152
Once you have pushed your local fix_455 branch to your remote forked repository
119
153
you can link:https://help.github.com/articles/creating-a-pull-request/[create] a
120
154
new pull request. You can create the pull request on the OpenSCAP's
121
155
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.
127
162
128
163
Developers and contributor that watch the repository should now
129
164
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
135
170
about your code you have to do some changes. There are two ways to change your
136
171
code in a submitted pull request:
137
172
138
- . Add a new commit or ,
139
- . edit existing commits.
173
+ . Add a new commit,
174
+ . or edit existing commits.
140
175
141
176
==== 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.
144
179
145
180
==== 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:
149
184
150
185
[[app-listing]]
151
186
[source,bash]
152
187
----
153
188
# 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
156
191
# make your changes
157
192
# vim my_source_file.c
158
193
# commit your new changes
159
194
$ 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
161
197
$ git rebase --continue
162
198
----
163
199
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
+
164
210
=== Closing the pull request
165
211
Once the pull request has been merged to upstream's branch the pull request will
166
212
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:
168
214
169
215
[[app-listing]]
170
216
[source,bash]
171
217
----
172
- # detele the fix_455 branch
218
+ # detele the fix_455 branch locally
173
219
$ 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
174
222
----
0 commit comments