OpenXcom Forum

Contributions => Programming => Topic started by: SupSuper on February 23, 2011, 05:22:29 pm

Title: [IMPORTANT] How to contribute code
Post by: SupSuper on February 23, 2011, 05:22:29 pm
If you wanna contribute with programming, this is the forum where you can post/discuss any possible fixes/improvements/etc. Please follow the coding guidelines and roadmap, and don't get over-ambitious and try to implement entire X-Com features on your own, specially without understanding how the whole project is organized and managed. This is still mostly a one/two-man operation, please respect that.

To send in code changes, don't post the modified source files, but use one of these methods:

Through GitHub:

Through a patch:
Title: Re: [IMPORTANT] How to contribute code
Post by: Fenyő on October 16, 2012, 01:22:32 pm
SupSuper!
I want to ask you a few questions about Github. (actually anyone can answer, if knows the answers :) )

Currently, i have forked the original OpenXcom just to be able to send in Pull-requests.
I've made my changes, and done a Pull-request.
Since i have forked you have made a commit to the original, but you still not responded to the Pull-request.
Now, i have pulled your new commit (UFOpaedia-related) and pushed it to my github-forked-repo.
But now i see it added my "merge" to my Pull-request as a new commit.
I don't want to add this "merge" to my Pull-request (because i don't want to re-add your commit), and i cannot remove it from there.
How can i remove it from there? Or it is not a problem if its there?

Next question.
What happens, if i modify a file, commit it, and i do a Pull-request on it, and before it is responded by you, the original file (which i've modified) changes with a new commit in the original?
If you accept my Pull-request then the changes not made by me will get lost?
Title: Re: [IMPORTANT] How to contribute code
Post by: SupSuper on October 16, 2012, 03:35:17 pm
SupSuper!
I want to ask you a few questions about Github. (actually anyone can answer, if knows the answers :) )

Currently, i have forked the original OpenXcom just to be able to send in Pull-requests.
I've made my changes, and done a Pull-request.
Since i have forked you have made a commit to the original, but you still not responded to the Pull-request.
Now, i have pulled your new commit (UFOpaedia-related) and pushed it to my github-forked-repo.
But now i see it added my "merge" to my Pull-request as a new commit.
I don't want to add this "merge" to my Pull-request (because i don't want to re-add your commit), and i cannot remove it from there.
How can i remove it from there? Or it is not a problem if its there?
When you make a pull request, you select which "branch" of your repository you wanna pull. GitHub automatically updates the pull request with any changes you make to that branch, so you can keep updating the pull request according to feedback.
Therefore it's good practice to make a separate branch for each pull request, so you can just keep making the changes you want without affecting your main development, and in the end merge it all back together. I've updated the instructions to reflect this, you can read more about pull requests here: https://help.github.com/articles/using-pull-requests

In your case, you pulled your "master" branch (your main repository), so any changes you make there will automatically be reflected. That extra commit doesn't seem to have caused any problems, but in the future make sure to make a separate branch so you don't get any unintended changes.

Next question.
What happens, if i modify a file, commit it, and i do a Pull-request on it, and before it is responded by you, the original file (which i've modified) changes with a new commit in the original?
If you accept my Pull-request then the changes not made by me will get lost?
Git will automatically try to merge the changes between both versions, so you don't have to worry about your pull request becoming invalid with other commits or something. You also don't need to keep your pull request "up to date" with the original repository (unless any changes affect your code), since Git only keeps track of the differences between files, so it always knows how to merge things.

I would recommend you read up on version control and Git, as it looks like you don't quite understand what you're dealing with. This is a good reference: https://git-scm.com/book
Title: Re: [IMPORTANT] How to contribute code
Post by: Fenyő on October 18, 2012, 11:02:53 pm
Git will automatically try to merge the changes between both versions, so you don't have to worry about your pull request becoming invalid with other commits or something.
And if the same lines are affected? :)
Title: Re: [IMPORTANT] How to contribute code
Post by: SupSuper on October 18, 2012, 11:14:01 pm
And if the same lines are affected? :)
Then there will be a conflict and Git will ask the developer to fix it themselves. This is standard for all version control systems.
Title: Re: [IMPORTANT] How to contribute code
Post by: Fenyő on October 21, 2012, 08:47:12 pm
Brrrr.
I'm really getting to hate github!  >:(

If i make a new branch, it not just gets in my refresh(merge) again like with master branch, it also gets my previous commit to the new Pull-request!! >:(

Now i have a new Pull-request which also contains my previous Pull-request! >:(

How the hell can i ERASE a commit from a Pull-request of mine?

EDIT:
THIS GITHUB IS A NIGHTMARE!!
!!I HATE IT!!


EDIT2: Ok, with a lot of experimenting i've managed to create a new branch and pull-request only with that one commit.
This github is a chaos!!
Title: Re: [IMPORTANT] How to contribute code
Post by: radius75 on October 22, 2012, 12:02:06 am
Always create new branch (for new issue /PR) from actually SupSuper/OpenXcom/master

Example:               (https://git-scm.com/downloads (https://git-scm.com/downloads))
Title: Re: [IMPORTANT] How to contribute code
Post by: SupSuper on October 22, 2012, 12:37:40 am
Brrrr.
I'm really getting to hate github!  >:(

If i make a new branch, it not just gets in my refresh(merge) again like with master branch, it also gets my previous commit to the new Pull-request!! >:(

Now i have a new Pull-request which also contains my previous Pull-request! >:(

How the hell can i ERASE a commit from a Pull-request of mine?

EDIT:
THIS GITHUB IS A NIGHTMARE!!
!!I HATE IT!!


EDIT2: Ok, with a lot of experimenting i've managed to create a new branch and pull-request only with that one commit.
This github is a chaos!!
Maybe if you didn't create so many pull requests at once this wouldn't happen. :P
Title: Re: [IMPORTANT] How to contribute code
Post by: Fenyő on October 22, 2012, 01:20:48 am
Always create new branch (for new issue /PR) from actually SupSuper/OpenXcom/master
Before i start coding, or after i finished coding?
Hmm, and I'm using tortoiseGit, as the wiki recommended, could this be a problem also?
Title: Re: [IMPORTANT] How to contribute code
Post by: radius75 on October 22, 2012, 10:35:18 am
Quote
Before i start coding, or after i finished coding?
Create new local Branch from 'remote upstream/master' (fetch for update) - [from remote SupSuper/OpenXcom - master]
Work on this Branch, 'Commit' proper changes and Push to 'remote origin' - [remote fenyo1/OpenXcom]

Create new local Branch before work on OpenXcom local repository.
Or always start work on 'local master' == 'remote upstream/master' (if they are identical)
 [Enough to be able then to create proper new branch (from remote upstream/master) before! confirming 'Commit' and 'Push' to 'remote origin']

I hope that I speak comprehensibly :)
Title: Re: [IMPORTANT] How to contribute code
Post by: Fenyő on October 22, 2012, 01:03:35 pm
start work on 'local master'
That's the thing which actually solved my problem yesterday.  ...After i experimented hours and cut up ugly.
(I've noticed that when i change branch locally in my folder, it actually changes my files!!
- This is horrible! This way i can not invent new things with having my previous invention!! (or it will commit that to the new PR again))
Title: Re: [IMPORTANT] How to contribute code
Post by: radius75 on October 22, 2012, 01:12:16 pm
Possible you changed only name of Branch, and new did not create.  (new from upstream/master)
That is why you sent the previous Commit to SupSuper/OprnXcom/master.

Or you created new local Branch from previous local Branch
Title: Re: [IMPORTANT] How to contribute code
Post by: Fenyő on October 22, 2012, 02:06:53 pm
Or you created new local Branch from previous local Branch
Yes, that was the reason!
I didn't know i have to change branch locally before start a new work.
(and this is horrible, that i have to change branch back, and temporarily loose the previous invention)
Title: Re: [IMPORTANT] How to contribute code
Post by: radius75 on October 22, 2012, 02:35:00 pm
If the previous commit are already merged to remote upstream/master, this doing new local Branch from upstream/master you will be have them.

You create PR from separate Branches and @SupSuper decides in what order merged or throw aside.
You have to wait from new PR, if @SupSuper makes 'merge' before you will propose next commit - if your PR is resulting from the previous proposals commits.
Because he can throw aside this PR.
So this works.

Title: Re: [IMPORTANT] How to contribute code
Post by: Warboy1982 on November 11, 2012, 02:49:52 am
Quote
don't get over-ambitious and try to implement entire X-Com features on your own

sorry to bother you, but, could i please get clarification on exactly what you mean here?

like, say for example, i want to add the ufo hyper detection screen (UfoHyperDetectedState), if i add this as a stand-alone "feature" without making any changes to the GeoscapeState (ie, calling the UfoHyperDetectedState) is that more or less acceptable?

or for another, more complex example, live alien research - which requires modifications to many existing classes - does this constitute an entire new feature, or an offshoot of an existing feature? even though it is much more complex (codewise) than the hyper-detection screen?

also, if i DO want to implement say... four features or so... am i better off to do that as four seperate branches or as a single amalgamated branch?

i merely ask because i want to help and contribute as much as i can, but i want to do it in the proper way that causes you the least amount of hassle/headache.
Title: Re: [IMPORTANT] How to contribute code
Post by: karvanit on November 11, 2012, 05:13:10 am
One feature in each PR, each PR in a separate branch, is the best way. Doing it like this, it's FAR easier for the integrator, and other people can easily help / comment / test on each feature.

Also, IMO, try to keep each commit clean and making a single (conceptual) change. eg HyperDecoder Ufopaedia, HyperDecode base facility, HyperDecoder UFO reporting = 3 commits. This makes it easier to comment / fix bugs, and to review the code changes.

Git tip: Try having a devel-feature local branch where you can do the actual work and mess with the history as often as you like (eg git rebase -i, git cherry-pick), and a clean feature branch you will push to GitHub.
Title: Re: [IMPORTANT] How to contribute code
Post by: Warboy1982 on November 11, 2012, 06:05:59 pm
so this would be the sort of pull request you'd LIKE to see?

https://github.com/SupSuper/OpenXcom/pull/184 (https://github.com/SupSuper/OpenXcom/pull/184)
Title: Re: [IMPORTANT] How to contribute code
Post by: karvanit on November 11, 2012, 08:53:36 pm
Speaking only for myself, I consider this form of PR extremely pullable!
Title: Re: [IMPORTANT] How to contribute code
Post by: SupSuper on November 11, 2012, 09:29:44 pm
Yeah, I've accepted it now. I usually don't have much comment on them, but the problem with pull requests is the bigger they are, the longer they take to review (gotta make sure nobody's sneaking any viruses or something :P) and the more likely they will conflict with some minor change, which just makes the merging process even more manual so I keep putting it off and... yeah. :P
Title: Re: [IMPORTANT] How to contribute code
Post by: Fenyő on November 12, 2012, 05:42:31 am
@SupSuper: Hmm, maybe this is the reason you haven't accepted my PR yet? :)
Do you want me to slice it to more commits? :)
Or maybe i can tell its way of work,  d' you want that?
Title: Re: [IMPORTANT] How to contribute code
Post by: SupSuper on November 13, 2012, 04:23:18 am
@SupSuper: Hmm, maybe this is the reason you haven't accepted my PR yet? :)
Do you want me to slice it to more commits? :)
Or maybe i can tell its way of work,  d' you want that?
You'll just have to be patient, no matter how you slice it, eventually all these huge pull requests are gonna touch the same files and I have to merge them in manually.
Title: Re: [IMPORTANT] How to contribute code
Post by: Fenyő on November 13, 2012, 04:54:19 am
May i ask which Pull-request is conflicting with mine?
Title: Re: [IMPORTANT] How to contribute code
Post by: SupSuper on November 16, 2012, 10:35:00 pm
May i ask which Pull-request is conflicting with mine?
The conflicts were in the project files since you all change those. :P
Title: Re: [IMPORTANT] How to contribute code
Post by: karvanit on November 21, 2012, 01:22:03 am
Another think to know / use:

When making git commits, the first line should be short (up to 50 characters), and be a meaning full description/title.
The next line should be empty.
This way the git history looks much nicer.
Title: Re: [IMPORTANT] How to contribute code
Post by: Warboy1982 on November 23, 2012, 11:02:29 am
Quote
The next line should be empty.

rrrrgh, sorry about this.
i thought i was doing it right, but i completely missed that there should be a blank line.
rest assured any future commits from me WILL conform to this standard.
Title: Re: [IMPORTANT] How to contribute code
Post by: Juju Dredd on August 28, 2013, 07:41:40 pm
Always create new branch (for new issue /PR) from actually SupSuper/OpenXcom/master

Example:               (https://git-scm.com/downloads (https://git-scm.com/downloads))

Thanks for this picture, I see I created my branch the wrong way.
Could somebody explain what the boxes "Tracking Branch" "Fast forward only" "Fecth tracking branch" are for?

Please please please, could someone reveal me the keys of (tortoise) git mysteries...

Edit: Oh no, I understand now, aliens must have abducted me and put something in my brain preventing it from functioning normally, you do not speak about TortoiseGit but GitGui...
Title: Re: [IMPORTANT] How to contribute code
Post by: Juju Dredd on August 29, 2013, 12:18:54 am
Could anybody tell me why I get a "Anonymous access denied" from GitHub when trying to push with TortoiseGit? Because I tried to configure a private/public key, and I must give my GitHub login and password. This is a strange anonymous access I believe...

Edit: OK, I made it, I just spent only five hours to do that simple operation...