If you want to contribute source code to pysdn then please read this document, it describes how to contribute your code to pysdn.
Why would you want to contribute source code?
- You have a bug fix
- You have a new feature
- You have some ideas
Typically the answer to this question is, "Hurray! Yes! Thank you! Definitely!" But lets communicate with the community to be sure there is no duplicate effort or that what you want to do is not a new github project altogether:
-
If you contribute a bug fix then please find or create an issue first (go to the github page for this repository and use the github issues page, on right margin). This is to
- track the issue
- be sure it is a bug (and not a misunderstanding of a feature)
- be sure it is not already being worked on
-
If you contribute a new feature it should match the goal/scope of this project: provide Python developers a Python library of classes to more easily work with Brocade's OpenDaylight Controller. This is to avoid feature creep and ensure that there are opportunities for others to build new github repositories with libraries and apps atop this library.
-
If something drives you nuts about using the API then log it as an issue and then see bug fix above.
-
If you have ideas for a better internal software design/architecture, log it as an issue so we can discuss it.
-
In general, it is better to communicate with us before launching into a large modification. We prefer to communicate publicly so that all users can participate if they so choose. Please go to the github page for this repository and use the github issues page.
When you do your first pull request we will ask you to sign a contributor license agreement (CLA). This is to ensure that we can keep pysdn open source for everyone. We thought that this StackOverflow answer did a good job describing the reasons for CLA: http://programmers.stackexchange.com/questions/168020/how-signing-out-a-cla-prevents-legal-issues-in-open-source-projects
- First, read the 'Will my contribution be accepted by the maintainer(s)' section above.
- We use the Fork & Pull methodology for pull requests as described here: https://help.github.com/articles/using-pull-requests/
- There is a good beginner video (by Ashley Grant) here as well: https://www.youtube.com/watch?v=M7ZYkjOWr6g
-
Fork this repository.
- Go to this repository's home page in Github and then in the top right corner find the 'Fork' button and click it.
-
Go to the newly forked repository's home page (in your Github account) and get its clone URL (on right margin)
-
On your laptop open a command window and clone your fork of the project
git clone <clone url of your fork of the project>
-
Change into the directory created
-
Set your local repo to track the original repository
git remote add upstream <clone url for the original project>
-
Never, Never, NEVER make changes in this master branch on your laptop. It will always be your copy of the original project and should never have changes you make. You will make your changes in feature branches. You may have only one feature branch or you may have multiples, depending on how many changes you are going to request be made to the original project.
-
In your console window in the forked project, change to the 'master' branch.
git checkout master
-
Now, 'rebase' your master to the upstream master branch of the original project (not your fork). This basically will make your local master branch match exactly what is on the remote master of the original project.
git pull --rebase upstream master
-
Create a feature branch for an issue/feature that you are writing code to address. For instance if you have two bug fixes and a new feature then each of those would have an associated github issue and each would be repaired in its own feature branch (so you would have three (3) feature branches). That way each change has an associated issue to track it and if one of your pull requests takes a long time to resolve and get into the original project the other ones can still get in quickly.
git checkout -b <name of your feature branch>
-
That command will create the branch and move you into that branch. Always double check which branch you are in...to avoid making changes in the wrong branch.
git branch
-
Send the new (local) feature branch to Github and connect that (remote) feature branch to this local branch
git push --all -u
-
If you are in the correct feature branch, then go ahead and make the changes to the source files that you want to make.
- Before making changes always be sure you are in the correct branch
git branch
-
Feel free to inform git about your changes to your local feature branch
git add <filename>
-
Feel free to commit your changes to your local feature branch
git commit -m "A reasonable sentence describing your changes"
-
Feel free to push your changes to your remote feature branch
git push
- Once you are happy with your changes run the unit tests to validate the system continues to work correctly (unit tests coming soon)
- Once the unit tests work add, commit and push all your changes to your remote feature branch (see above)
- Once all your changes are pushed you are ready to do a pull request
- Open your browser and go to your fork of the project (not the original), find your feature branch and do a compare and pull request
- If the pull request is able to be merged automatically then go ahead and create the pull request
- If the pull request cannot be merged automatically then see 'How do I rebase?' below and then come back here and try again.
-
Sometimes your pull request cannot be merged automatically or the maintainer responds to your pull request with 'please rebase and try again'. Basically this means that other changes (pull requests) have slipped in front of you and your request can no longer be merged automatically. This section describes how to do this.
-
This works only if you Never, Never, NEVER make changes in your fork's master branch and only make changes in the feature branches.
-
In your console window in the forked project, change to the 'master' branch.
git checkout master
-
Now, 'rebase' your master to the upstream master branch of the original project (not your fork). This basically will make your local master branch match exactly what is on the remote master of the original project.
git pull --rebase upstream master
-
Now, change back to your feature branch
git checkout <feature branch name>
-
Rebase your feature branch to your local master branch. This will make your feature branch identical to your local master branch and then replay all of the changes you made on your feature branch on top of this.
git rebase master
-
Check the output of the last command. Did you get CONFLICT messages? If yes, then you need to open the files that had CONFLICT, look at them and figure out how to merge the conflicts. The conflicts will be marked in the files. The CONFLICT areas will begin with <<<<< and end with >>>> In between these will be your original text and the text from the current project.
-
Once you resolve all the conflicts and run the unit tests (coming soon) you are ready to finish the rebase:
-
Inform git about all the files you changed by doing a git add for each
git add <filename of files changed>
-
Let git know that you have completed fixing the CONFLICT and it should continue the rebase
git rebase --continue
-
Force push your changes
git push --force
-
You have rebased. Go back to the previous section and try sending your pull again.