Author Topic: [IMPORTANT] How to contribute code  (Read 48626 times)

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
[IMPORTANT] How to contribute code
« 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:
  • Make a local clone of the repository.
  • Commit the changes you wanna contribute on your local copy.
  • Make a patch of your commits through the terminal or your favorite Git client (eg. "Create Patch Serial" in TortoiseGit).
  • Post the patch on this forum.
« Last Edit: October 16, 2012, 03:42:19 pm by SupSuper »

Offline Fenyő

  • Colonel
  • ****
  • Posts: 423
    • View Profile
Re: [IMPORTANT] How to contribute code
« Reply #1 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?
« Last Edit: October 16, 2012, 01:24:56 pm by fenyo1 »

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: [IMPORTANT] How to contribute code
« Reply #2 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
« Last Edit: October 16, 2012, 03:40:45 pm by SupSuper »

Offline Fenyő

  • Colonel
  • ****
  • Posts: 423
    • View Profile
Re: [IMPORTANT] How to contribute code
« Reply #3 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? :)

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: [IMPORTANT] How to contribute code
« Reply #4 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.

Offline Fenyő

  • Colonel
  • ****
  • Posts: 423
    • View Profile
Re: [IMPORTANT] How to contribute code
« Reply #5 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!!
« Last Edit: October 21, 2012, 09:42:53 pm by fenyo1 »

Offline radius75

  • Colonel
  • ****
  • Posts: 108
  • I am the average PC user!
    • View Profile
Re: [IMPORTANT] How to contribute code
« Reply #6 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)
« Last Edit: October 22, 2012, 12:17:59 am by radius75 »

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: [IMPORTANT] How to contribute code
« Reply #7 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

Offline Fenyő

  • Colonel
  • ****
  • Posts: 423
    • View Profile
Re: [IMPORTANT] How to contribute code
« Reply #8 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?

Offline radius75

  • Colonel
  • ****
  • Posts: 108
  • I am the average PC user!
    • View Profile
Re: [IMPORTANT] How to contribute code
« Reply #9 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 :)
« Last Edit: October 22, 2012, 11:10:21 am by radius75 »

Offline Fenyő

  • Colonel
  • ****
  • Posts: 423
    • View Profile
Re: [IMPORTANT] How to contribute code
« Reply #10 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))

Offline radius75

  • Colonel
  • ****
  • Posts: 108
  • I am the average PC user!
    • View Profile
Re: [IMPORTANT] How to contribute code
« Reply #11 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
« Last Edit: October 22, 2012, 01:15:11 pm by radius75 »

Offline Fenyő

  • Colonel
  • ****
  • Posts: 423
    • View Profile
Re: [IMPORTANT] How to contribute code
« Reply #12 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)

Offline radius75

  • Colonel
  • ****
  • Posts: 108
  • I am the average PC user!
    • View Profile
Re: [IMPORTANT] How to contribute code
« Reply #13 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.


Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: [IMPORTANT] How to contribute code
« Reply #14 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.