Merging my patches into source code

Merging my patches into source code

Postby paul424 » 05 Jul 2015, 11:49

Naah I try to return to work for OD, problem is I used to forgot a lot, I say sorry for this.
I remember Beratram gave list of what I need to do to publish my patches into OD.
If someone could redigg that, I would be gladful .
I have created auto-scrolling option under https://github.com/tomluchowski/OpenDungeons what do I need to merge that into official repo ?
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: Merging my patches into source code

Postby hwoarangmy » 05 Jul 2015, 21:50

I was going to do some wiki about this as it is not straight forward until you know the commands. To go faster, I will post you some notes I've taken ASAP.
hwoarangmy
 
Posts: 567
Joined: 16 Apr 2014, 19:13

Re: Merging my patches into source code

Postby hwoarangmy » 05 Jul 2015, 23:08

This is intended to be a first step for the wiki and, thus I will start from the begining to once the Pull Request (PR) is merged. I'm not a git expert so I will only explain what I do and why. There might be better ways to do the same but what I do will be good for 99% of the times (until now, it has been for me for 100% ^^). For most operations, I use console commands but for creating commits, I prefer to use the git GUI that allows to see changed files and see the differences.

First, you need a github account to be able to fork the sources and, later, create a PR.
Once you have your github account, log in and go to OpenDungeons (OD) repository:
https://github.com/OpenDungeons/OpenDungeons

Clic the "fork" button. This will create a copy of the latest OD sources in your own github account (it takes a few seconds).
Then, it's time to get the sources. Open a command console and go where you want to download sources. For example: c:\dev.
Download the sources. In my case, my user account is hwoarangmy and I want to download sources in c:\dev\od-gh-src
{l Code}: {l Select All Code}
cd dev
git clone https://github.com/hwoarangmy/OpenDungeons.git od-gh-src

Note that downloading sources may take some time depending on your internet connexion speed.

Now, you can compile the sources. If you want to see how to, go to:
https://github.com/OpenDungeons/OpenDun ... ki/Compile

Then, you can go for this great fix that the whole world is waiting for. And change the sources at will.

Once you have done something you are happy with, it's time to commit your work. I usually use git GUI for that as it is pretty nice and straight forward. Note that you may have more than 1 commit in a pull request. Since you don't pay for them, do not hesitate to split changes in several commits if you are doing something big as it is easier to read (avoid having 1 commit with a new feature + code cleaning + variable renaming + ...) and prefer to have 1 feature per commit.

Now that your work is commited, you might want to create a PR so that it is merged in the main repository. However, between the time you downloaded the sources and the time you are creating the PR, one of thoses lazy developers from OD team might have updated the repository. Now, you need to rebase your local repository to make sure your code can still be merged. Note that you need to have no uncommited changes in your local repository to be allowed to rebase. The command is:
{l Code}: {l Select All Code}
git pull --rebase git://github.com/OpenDungeons/OpenDungeons.git development


Here, we have 2 ways.
1 - There is no conflict, nobody changed the same code as you did. However, even if the probability is low that something was broken, you should check that your code still compiles. An error might happen, for example, if you added a call to a function that somebody erased/renamed. That's why this step is important. If everything goes well, you can upload your changes to your github account. To do that:
{l Code}: {l Select All Code}
git push origin development


Now, you can go to your github account website to create the pull request:
https://github.com/hwoarangmy/OpenDungeons

Click on the green button "create a pull request".
github will display the list of commits and the corresponding changes if you want to review them. If everythig is ok, you can click "create the pull request".

That's all. Now, you need to wait for someone else to review your code and merge it if everything is ok.

2 - There is a conflict. Somebody changed code in the same area as you did. You need to resolve the conflicts. If you don't have the correct tools installed, you can run:
{l Code}: {l Select All Code}
git mergetool --tool-help

For my part, I've installed tortoisemerge. I didn't know this tool or the others so I just randomly picked this one.

Now, you can go for resolving conflicts. Run:
{l Code}: {l Select All Code}
git mergetool

It should run the chosen tool and open the conflicting items. Once you have resolved everything, you can go on with the rebasing:
{l Code}: {l Select All Code}
git rebase --continue


You can test that everything still compiles (resolving merge conflicts might not be easy and it is easy to break stuff at this stage).
If everything goes well, you can upload your changes to your github account. To do that:
{l Code}: {l Select All Code}
git push origin development


Now, you can go to your github account website to create the pull request:
https://github.com/hwoarangmy/OpenDungeons

Click on the green button "create a pull request".
github will display the list of commits and the corresponding changes if you want to review them. If everythig is ok, you can click "create the pull request".

That's all. Now, you need to wait for someone else to review your code and merge it if everything is ok.

Side notes:
- If 2 persons create 2 PR at the same time that conflicts each others, once one will be merged, the second will be displayed as not mergeable. If that happens, you should rebase your local repository, resolve the conflicts and add the corresponding new commits.
- In OD, nobody merges his own PR. Someone else have to review the code and to merge it. That allows thatsomeone else have approved the code (and checked for minor errors, code rules, architecture compatibility, ...). That also allows other coders to follow how the code evolves.
- Note that as long as you have a PR open, every commit that will be uplodaded to github will automatically by added to the PR unless you create a new branch.
hwoarangmy
 
Posts: 567
Joined: 16 Apr 2014, 19:13

Re: Merging my patches into source code

Postby Bertram » 09 Jul 2015, 08:04

Just perfect. :)
Thanks for taking care of this hwoarangmy.

I'll add that in this specific case, the code is based on a old version, as we now have a lot of changes in the camera management, and a new options menu.
There are also comments from Akien and me that are IMHO to be fixed before going further.

Regards,
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Who is online

Users browsing this forum: No registered users and 1 guest