How to contribute
Version 37 (Daniil Osokin, 2014-07-14 06:01 pm)
1 | 13 | Daniil Osokin | {{>toc}} |
---|---|---|---|
2 | 13 | Daniil Osokin | |
3 | 1 | h1. How to contribute |
|
4 | 1 | ||
5 | 16 | Daniil Osokin | We suppose that you've seen the http://opencv.org/contribute.html page, and now, as an enthusiastic coder, want to contribute some code. For that purpose OpenCV project now has a mirror on the GitHub, to simplify everybody's life! All the bug fixes, new functionality, new tutorials etc. should be submitted via the GitHub's mechanism of pull requests. |
6 | 1 | ||
7 | 16 | Daniil Osokin | If you are not familiar with the mechanism - do not worry, it's very simple. Keep reading. |
8 | 1 | ||
9 | 24 | Daniil Osokin | h2. "Fork & Pull Request model" for code contribution |
10 | 13 | Daniil Osokin | |
11 | 32 | Daniil Osokin | h3. *Short instruction* |
12 | 32 | Daniil Osokin | |
13 | 16 | Daniil Osokin | # Install [[Git]]. |
14 | 16 | Daniil Osokin | # Register at GitHub. Create your fork of OpenCV repository https://github.com/Itseez/opencv (see https://help.github.com/articles/fork-a-repo for details). |
15 | 29 | Daniil Osokin | # Choose a task for youself. It could be a "bugfix":http://www.code.opencv.org/projects/opencv/issues?query_id=5, or some new code. |
16 | 30 | Daniil Osokin | # Choose a base branch for your work. You have two options: |
17 | 30 | Daniil Osokin | ## *2.4* - the branch that will be used for future minor releases in the 2.4.x line. Choose it when fixing a bug that's reproducible in this branch, or when making performance optimizations relevant to it. 2.4 has been feature-frozen; as such, new functionality will _not_ be accepted. |
18 | 30 | Daniil Osokin | ## *master* - the branch that will be used for the next major release of OpenCV (tentatively, 3.0). Choose it when adding new functionality, or for bugfixes/optimizations that don't apply to 2.4. |
19 | 16 | Daniil Osokin | # Create a new branch (with a meaningful name) from the base branch you chose. |
20 | 1 | # Modify/add the code following our [[Coding Style Guide]]. |
|
21 | 32 | Daniil Osokin | # When you are done, push your branch to your GitHub fork; then create a pull request from your branch to the base branch (see https://help.github.com/articles/using-pull-requests for details). |
22 | 1 | ||
23 | 32 | Daniil Osokin | h3. *Links to "step-by-step" guide for popular systems and clients* |
24 | 32 | Daniil Osokin | |
25 | 34 | Daniil Osokin | * [[How to contribute#Windows-7-and-TortoiseGit|Windows 7 and TortoiseGit]] |
26 | 32 | Daniil Osokin | |
27 | 31 | Daniil Osokin | h2. Making a good pull request |
28 | 31 | Daniil Osokin | |
29 | 31 | Daniil Osokin | Following these guidelines will increase the likelihood of your pull request being accepted: |
30 | 31 | Daniil Osokin | |
31 | 31 | Daniil Osokin | # Scope your PR to one issue. Before submitting, make sure the diff contains no unrelated changes. If you want to cover more than one issue, submit your changes for each as separate pull requests. |
32 | 31 | Daniil Osokin | # If you have added new functionality, you should update/create the relevant documentation, as well as add tests for it to the testsuite. |
33 | 31 | Daniil Osokin | # Try not to include "oops" commits - ones that just fix an error in the previous commit. If you have those, then before submitting "squash":http://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits those fixes directly into the commits where they belong. |
34 | 31 | Daniil Osokin | # Make sure to choose the right base branch and to follow the [[Style Guide]] for your code. |
35 | 31 | Daniil Osokin | |
36 | 16 | Daniil Osokin | h2. Testing and merging of pull requests |
37 | 4 | Daniil Osokin | |
38 | 16 | Daniil Osokin | # Your pull request will be automatically tested by OpenCV's buildbot (testing status can be checked here: http://pullrequest.opencv.org). If any builders are failed, you should fix the issue. As you fix the code and push changes to your branch at github, buildbot reruns automatically. _No need to close pull request and open a new one!_ |
39 | 16 | Daniil Osokin | # Once all the builders are "green", one of OpenCV developers will review your code. Reviewer could ask you to modify your pull request. Please provide timely response for reviewers (within weeks, not months), otherwise you submission could be postponed or even rejected. |
40 | 9 | Daniil Osokin | |
41 | 18 | Daniil Osokin | h3. Here is the flow-chart of the process: |
42 | 19 | Daniil Osokin | |
43 | 4 | Daniil Osokin | !https://docs.google.com/drawings/pub?id=1_m7oVQ4CvoMxZn63N1_TyhhazmLLWY5uLEGUyPCERLo&w=960&h=720! |
44 | 4 | Daniil Osokin | |
45 | 16 | Daniil Osokin | h2. Happy End |
46 | 1 | ||
47 | 23 | Daniil Osokin | # As soon as the reviewer is fine with the pull request and BuildBot likes your code, the special comment ":+1:" or ":shipit:" is put, which signals OpenCV maintainers that they can merge your pull request. |
48 | 1 | # The last, but not least. Make sure you got credits. We try to memorize all the contributions and list major ones in the [[ChangeLog]] and release announcements, but we may forget to do that, unintentionally. Please, do not hesitate to remind us, and we will update opencv.org and the ChangeLog accordingly. |
|
49 | 32 | Daniil Osokin | |
50 | 32 | Daniil Osokin | h1. "Step-by-step" guide for popular systems and clients |
51 | 32 | Daniil Osokin | |
52 | 34 | Daniil Osokin | h2. {{anchor|Windows 7 and TortoiseGit}}Windows 7 and TortoiseGit |
53 | 33 | Daniil Osokin | |
54 | 33 | Daniil Osokin | *System configuration:* |
55 | 33 | Daniil Osokin | |
56 | 33 | Daniil Osokin | * Windows 7 x64 bit operating system. |
57 | 33 | Daniil Osokin | * Git 1.8.1 & TortoiseGit 1.8.4. |
58 | 33 | Daniil Osokin | |
59 | 33 | Daniil Osokin | *Prerequisites:* |
60 | 33 | Daniil Osokin | |
61 | 33 | Daniil Osokin | # Register at GitHub. |
62 | 33 | Daniil Osokin | # Download & install "Git":http://code.google.com/p/msysgit/downloads/list. |
63 | 33 | Daniil Osokin | # Download & install "TortoiseGit":http://code.google.com/p/tortoisegit/wiki/Download. |
64 | 33 | Daniil Osokin | |
65 | 33 | Daniil Osokin | Firstly, *configure your GitHub page* to fork the original OpenCV repository: |
66 | 33 | Daniil Osokin | |
67 | 1 | # Go to GitHub. |
|
68 | 33 | Daniil Osokin | # Open the "Itseez OpenCV page":https://github.com/Itseez/opencv. |
69 | 34 | Daniil Osokin | # Press the fork icon on the right hand top side of the page: |
70 | 34 | Daniil Osokin | |
71 | 1 | !press_fork_button.png! |
|
72 | 34 | Daniil Osokin | |
73 | 34 | Daniil Osokin | Create a folder on your system to *sync up the OpenCV source code* from your fork: |
74 | 34 | Daniil Osokin | |
75 | 34 | Daniil Osokin | * Create a folder named 'opencv_source' in your systems root path (or your own selection). |
76 | 34 | Daniil Osokin | * Right click on the folder, selecting the Git Clone option: |
77 | 34 | Daniil Osokin | |
78 | 34 | Daniil Osokin | !git_clone.png! |
79 | 34 | Daniil Osokin | |
80 | 34 | Daniil Osokin | * Fill in the proper information into the configuration panel. Replace "StevenPuttemans" username with your GitHub username and remove the extra opencv folder that is added to the directory structure: |
81 | 34 | Daniil Osokin | |
82 | 34 | Daniil Osokin | !clone_existing_repository! |
83 | 34 | Daniil Osokin | |
84 | 34 | Daniil Osokin | * Press OK and let the folder sync up, until full synchronization has passed: |
85 | 34 | Daniil Osokin | |
86 | 34 | Daniil Osokin | !synchronization_with_Itseez_git.png! |
87 | 35 | Daniil Osokin | |
88 | 35 | Daniil Osokin | *Create a new branch on your Git repository*, to apply changes. Do not forget to create a new branch for every single update you want to do! _These branches are local, but will be pushed to github after editing the source code._ |
89 | 35 | Daniil Osokin | |
90 | 35 | Daniil Osokin | * Right click on folder. |
91 | 35 | Daniil Osokin | * Select TortoiseGit > Create Branch: |
92 | 35 | Daniil Osokin | |
93 | 35 | Daniil Osokin | !create_branch.png! |
94 | 35 | Daniil Osokin | |
95 | 35 | Daniil Osokin | Select the correct options, choose a correct name for your branch, base it on the *master branch* for complete *new functionality*, or for *minor fix*, base it on *2.4 branch*: |
96 | 35 | Daniil Osokin | |
97 | 35 | Daniil Osokin | !choose_base_branch.png! |
98 | 35 | Daniil Osokin | |
99 | 35 | Daniil Osokin | * Hit the OK button and let it configure your repository. Changes might not change immediatly on the GitHub page, because it sync's in a lapsed time interval. Don't worry about that. |
100 | 35 | Daniil Osokin | |
101 | 35 | Daniil Osokin | !switched_to_branch.png! |
102 | 35 | Daniil Osokin | |
103 | 36 | Daniil Osokin | *Select the file you want to adapt* (in our case it's an adding extra comment to a source code file), *adapt the the file accordingly* and *commit it to your GitHub repository*. |
104 | 35 | Daniil Osokin | |
105 | 35 | Daniil Osokin | * In your configured GitHub folder on your machine, adapt the file you want. |
106 | 35 | Daniil Osokin | * In our case, we open up the file *C:\opencv_source\apps\traincascade\traincascade.cpp*. |
107 | 35 | Daniil Osokin | * Add your lines of code to the source code: |
108 | 35 | Daniil Osokin | |
109 | 35 | Daniil Osokin | !modify_opencv_source.png! |
110 | 35 | Daniil Osokin | |
111 | 35 | Daniil Osokin | |
112 | 35 | Daniil Osokin | * Save the file so that your adaptations are stored onto the system. |
113 | 35 | Daniil Osokin | * Your folder will indicate that a change has been made, by placing an exclamation mark: |
114 | 35 | Daniil Osokin | |
115 | 35 | Daniil Osokin | !opencv_source_folder_has_changed_files.png! |
116 | 35 | Daniil Osokin | |
117 | 35 | Daniil Osokin | * Commit your adapted file to GitHub by selecting the commit->bugfix_1 option: |
118 | 35 | Daniil Osokin | |
119 | 35 | Daniil Osokin | !commit_changes.png! |
120 | 35 | Daniil Osokin | * The first time, the system will ask you to input your username and email, giving the following warning. Press *Yes*, fill in credentials and press *OK*: |
121 | 35 | Daniil Osokin | |
122 | 35 | Daniil Osokin | !set_username_alert.png! |
123 | 35 | Daniil Osokin | |
124 | 35 | Daniil Osokin | !set_username_and_email.png! |
125 | 35 | Daniil Osokin | |
126 | 35 | Daniil Osokin | * A commit window of TortoiseGit will appear, showing you the files that were adapted. It requires you to give a complete but brief description of your adaptation, then allows you to push the file. Select only the files you want to commit to the repository! |
127 | 35 | Daniil Osokin | |
128 | 35 | Daniil Osokin | !commit_window.png! |
129 | 35 | Daniil Osokin | |
130 | 35 | Daniil Osokin | * At the next window, explicitly tell the software to push the adaptations! |
131 | 35 | Daniil Osokin | |
132 | 1 | !select_push_changes.png! |
|
133 | 36 | Daniil Osokin | |
134 | 36 | Daniil Osokin | * An interface will pop up to push the data and local branches (which you made earlier). Be sure to select the option to push all branches: |
135 | 36 | Daniil Osokin | |
136 | 36 | Daniil Osokin | !push_changes.png! |
137 | 36 | Daniil Osokin | |
138 | 36 | Daniil Osokin | Your system is now *all sync'd up with GitHub*, lets make sure by checking. |
139 | 36 | Daniil Osokin | |
140 | 36 | Daniil Osokin | * The branch you created for the fix should be visible in the branch setup. Select the one you just created: |
141 | 36 | Daniil Osokin | |
142 | 36 | Daniil Osokin | !check_branch_with_bugfix_on_github.png! |
143 | 36 | Daniil Osokin | |
144 | 36 | Daniil Osokin | * Check the file and see if adaptations worked. Also check if other branches stay clear of changes, which should be if you did everything correct: |
145 | 36 | Daniil Osokin | |
146 | 36 | Daniil Osokin | !check_commit_on_github.png! |
147 | 36 | Daniil Osokin | |
148 | 36 | Daniil Osokin | Last step, *creating a pull request*! |
149 | 36 | Daniil Osokin | |
150 | 36 | Daniil Osokin | * Go to the GitHub website and open your own repository. |
151 | 36 | Daniil Osokin | * Click on the pull-requests button: |
152 | 36 | Daniil Osokin | |
153 | 36 | Daniil Osokin | !click_on_pull_requests.png! |
154 | 36 | Daniil Osokin | |
155 | 36 | Daniil Osokin | * Push the 'new pull request' button: |
156 | 36 | Daniil Osokin | |
157 | 36 | Daniil Osokin | !push_new_pull_request_button.png! |
158 | 36 | Daniil Osokin | |
159 | 36 | Daniil Osokin | Since we have only a comment to add, we would like to select the 2.4 branch, not the master branch, which is for future functionality mainly, not for small bugfixes. |
160 | 36 | Daniil Osokin | |
161 | 36 | Daniil Osokin | * Start by selecting the option to compare over forks: |
162 | 36 | Daniil Osokin | |
163 | 36 | Daniil Osokin | !edit_branches_for_pull_request.png! |
164 | 36 | Daniil Osokin | |
165 | 36 | Daniil Osokin | * Then select the correct branches of each fork to compare. For StevenPuttemans/opencv it's 'bugfix_1' and '2.4' for the Itseez/opencv: |
166 | 36 | Daniil Osokin | |
167 | 36 | Daniil Osokin | !select_branches_for_pull_request.png! |
168 | 36 | Daniil Osokin | |
169 | 36 | Daniil Osokin | * Immediatly we can see, that there is a single file found, which is different between the current '2.4' branch on Itseez/opencv and the 'bugfix_1' branch on StevenPuttemans/opencv. We now assign a pull request at this change (which is basically asking to upload your code to the sourcecode of OpenCV). |
170 | 36 | Daniil Osokin | * Click to create a pull request at the designated button (see previous image). |
171 | 36 | Daniil Osokin | * Do not forget to add some explanation on what your add-on does exactly. Then click the send pull request button: |
172 | 36 | Daniil Osokin | |
173 | 36 | Daniil Osokin | !add_pull_request_description.png! |
174 | 36 | Daniil Osokin | |
175 | 37 | Daniil Osokin | * *This all will result in an actual pull request being pushed towards the source code manager*. *Congratulations!* Now wait and go check from time to time, to make sure the developpers don't ask you to change something drastically: |
176 | 36 | Daniil Osokin | |
177 | 36 | Daniil Osokin | !pull_request_created.png! |
178 | 36 | Daniil Osokin | |
179 | 36 | Daniil Osokin | A last step you should consider, is going back to the "Issue tracker":http://code.opencv.org and add the link to your pull request at the actual bugfix task. The bug will then be automatically closed, once your pull request has been merged. |