XCode and local GitHub branches

Questions, problems and discussion about compiling FreeOrion.

Moderator: Oberlus

Post Reply
Message
Author
User avatar
mem359
Dyson Forest
Posts: 214
Joined: Sun Jun 08, 2014 1:18 am

XCode and local GitHub branches

#1 Post by mem359 »

Right now I have the Mac OSX SDK, and it has the latest code from the master branch (freeorion:master).
(Very new to the GitHub environment, and working with remote code repositories.)

Suppose I wanted to test a PR, for example the code in the branch "Morlic-fo:CarrierVsPlanets".
How do I go about getting those code changes from XCode?

Or do I need to go to the "file changed" GitHub website tab, look over the "diff", and make those changes myself?

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: XCode and local GitHub branches

#2 Post by Geoff the Medio »

There are probably better methods, but the most reliable method I've found (on Windows) is to go to the pull request's page, scroll down to the part below the integration build reports, where there is a link to show the command line instructions. Click the button to copy the commands for "Step 1: From your project repository, check out a new branch and test the changes." Then paste those into a command line in the directory where you've got the repository (for me, C:\Users\Geoff\Desktop\FreeOrionSDK5\FreeOrion ). Then build.

Quirks may occur if the branch is updated after you first pull it, and you want to pull again. The most reliable method I've found in that case is to switch back to master, delete the local branch, then re-create and pull it again using the same method as above.
Attachments
getting a branch
getting a branch
get_branch.png (73.04 KiB) Viewed 10815 times

User avatar
mem359
Dyson Forest
Posts: 214
Joined: Sun Jun 08, 2014 1:18 am

Re: XCode and local GitHub branches

#3 Post by mem359 »

Geoff the Medio wrote:...go to the pull request's page, scroll down to the part below the integration build reports, where there is a link to show the command line instructions...
I do not see an integration build report on the web page.

While looking at some of the discussions on the bug and PR pages, there were mentions of work tools like "Travis CI" and "Appveyor". Do I need that (or other tools) in order to get the extra information that you are seeing?

------

On a side note, that attached image helped a lot.
That clued me in to the protocol for seeing other people's branches (in your example, LGM-Doyle).
It probably isn't the best way, but I can find Morlic-fo's branch CarrierVsPlanets and download a copy. (Then I can copy the changed files to my FO build).

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: XCode and local GitHub branches

#4 Post by Geoff the Medio »

Hmm, indeed that section is missing when I view the pull request page not logged in. In that case, I don't know how people who aren't logged in are supposed to check out pull requests to test. Someone else will have to comment on that.

Alternatively, google it. I suspect the issue has come up many times...

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: XCode and local GitHub branches

#5 Post by adrian_broher »

I don't know how people who aren't logged in are supposed to check out pull requests to test.
I would assume "not at all". How are supposed to give feedback on a Pull Request if you can't write comments on it because you don't have a GitHub account (or are not logged in to GitHub)?
While looking at some of the discussions on the bug and PR pages, there were mentions of work tools like "Travis CI" and "Appveyor".
You can't install any of those, as they are services and not programs. See also: http://www.freeorion.org/forum/viewtopi ... =9&t=10420
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: XCode and local GitHub branches

#6 Post by Geoff the Medio »

adrian_broher wrote:I would assume "not at all". How are supposed to give feedback on a Pull Request if you can't write comments on it because you don't have a GitHub account (or are not logged in to GitHub)?
I would guess that potential testers would be more likely to check out and test a pull request if they could do so without having to make an account first, and that after having tested and found something they wanted to comment about it, they might then make the account to be able to do so.

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: XCode and local GitHub branches

#7 Post by adrian_broher »

Geoff the Medio wrote:
adrian_broher wrote:I would assume "not at all". How are supposed to give feedback on a Pull Request if you can't write comments on it because you don't have a GitHub account (or are not logged in to GitHub)?
I would guess that potential testers would be more likely to check out and test a pull request if they could do so without having to make an account first, and that after having tested and found something they wanted to comment about it, they might then make the account to be able to do so.
Well, GitHub seems to disagree with your opinion so no point discussing that.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: XCode and local GitHub branches

#8 Post by adrian_broher »

How do I go about getting those code changes from XCode?
Probably the best way to go for your would be the hub tool provided by github. It add an additional layer on top of the `git` tool and allows you to feed git some github url and do the right thing. However I don't know if it needs a GitHub account or not (I would assume not).

For example checking out a pull request:

git checkout https://github.com/github/hub/pull/134

Which is exactly the same URL as you would use to visit the discussion page of a pull request.
Or do I need to go to the "file changed" GitHub website tab, look over the "diff", and make those changes myself?
Unless you have nothing better to do I would advise against that.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: XCode and local GitHub branches

#9 Post by adrian_broher »

There is also the GitHub manual:

https://help.github.com/articles/checki ... atform-mac

Follow the section "Modifying an inactive pull request locally"; steps 1 to 6. The steps after that are for pushing changes to the PR, which you're not allowed to anyway.
Last edited by adrian_broher on Mon Mar 27, 2017 3:06 pm, edited 1 time in total.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
mem359
Dyson Forest
Posts: 214
Joined: Sun Jun 08, 2014 1:18 am

Re: XCode and local GitHub branches

#10 Post by mem359 »

I have a github account (memem359). Was logged in the whole time.

I've attached a PDF of what I see on the PR page.
(Maybe the ib report staring me in the face, and hiding in my blind spot?)

In any case, I've found a solution for my situation, and I'll post that next (so I don't forget).
Attachments
we can't attach PDF files? hmm, try jpg instead
we can't attach PDF files? hmm, try jpg instead
github_pr_page.jpg (308.99 KiB) Viewed 10803 times

User avatar
mem359
Dyson Forest
Posts: 214
Joined: Sun Jun 08, 2014 1:18 am

Re: XCode and local GitHub branches

#11 Post by mem359 »

Maybe this will help someone else who is (also) inexperienced with XCode/GitHub/FO.
(And in case I forget this in the future.)
  • Open XCode with the FO Mac OSX SDK. (I assume that the origin/master code has already been downloaded.)
  • Source Control -> (whatever your Working Copy is named, has a right triangle) -> Configure (last item after the branch options)
  • In the Configure drop down window, click the "Remotes" tab. Hit the "+" button -> Add Remote
  • Fill in the information. The address will be "https://github.com/(user_name)/freeorion.git", where you need to fill in the appropriate user name.
  • Now when I go to Source Control -> Pull... the scrolling options will include all the branches that user has in their GitHub repository. (Just need to match what was listed on the Pull Request web page.)

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: XCode and local GitHub branches

#12 Post by MatGB »

OK, the easiest way for a tester/scripter is to have a version of Git installed on their machine and then learn how to configure a Remote.

I've been meaning to write up a howto for ages but today I still have flu symptoms so this is a summary and hopefully together we can work it through.

First, you need to clone the FO repo using Git. Then tell your game client to use the Git repo on your machine not the default from the install: that's in Options (NB: I have zero clue how Macs work or how things're installed on them so I'm not going to go into detail on this, you may already have needed a copy of the source code).

Once you've done that, using the Command line/GitBash console to create a Remote called 'morlic' (I found instructions easily online, create new Git remore is a good search term), usign the URL of Morlic-fo's FO github clone.

Then, you need to checkout that branch, so 'git checkout morlic/CarrierVsPlanets'

This will put you into what's called "detached head" status where you're playing with a copy of a repo, you can branch off it and make changes but you don't need to. That should work.

There might be a need to rebase things onto master for the most recent test release, if that is needed then further instructions can be written.

We do need to have a "how to use git to test stuff" set of instructions for tester/low level scripters/players and I've been meaning to writ it up for ages, perhaps if you get this going OK you could help with it? Experienced coders need to learn Git proper, you and I don't really, but being able to test a PR that just changes scripts is very useful.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

dbenage-cx
Programmer
Posts: 389
Joined: Sun Feb 14, 2016 12:08 am

Re: XCode and local GitHub branches

#13 Post by dbenage-cx »

I've always done it same as MatGB, which does not need any login (and does not need a PR).
Just to reiterate, given a cloned freeorion repo:

Add remote: once for any persons repo :

Code: Select all

git remote add Morlic-fo https://github.com/Morlic-fo/freeorion/freeorion.git
Fetch: any time the repo changes, before switching to their branch:

Code: Select all

git fetch Morlic-fo
Checkout: the branch of a PR is listed in the top right (Morlic-fo:CarrierVsPlanets)

Code: Select all

git checkout Morlic-fo/CarrierVsPlanets
Maybe over-cautionary, but I also remove *.pyc files if there are *.py changes.
the hub tool provided by github
Outside of not needing to setup and sync a remote, are there other benefits to this?
Any content posted should be considered licensed GNU GPL 2.0 and/or CC-BY-SA 3.0 as appropriate.

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: XCode and local GitHub branches

#14 Post by Vezzra »

mem359 wrote:Maybe this will help someone else who is (also) inexperienced with XCode/GitHub/FO.
(And in case I forget this in the future.)
  • Open XCode with the FO Mac OSX SDK. (I assume that the origin/master code has already been downloaded.)
  • Source Control -> (whatever your Working Copy is named, has a right triangle) -> Configure (last item after the branch options)
  • In the Configure drop down window, click the "Remotes" tab. Hit the "+" button -> Add Remote
  • Fill in the information. The address will be "https://github.com/(user_name)/freeorion.git", where you need to fill in the appropriate user name.
  • Now when I go to Source Control -> Pull... the scrolling options will include all the branches that user has in their GitHub repository. (Just need to match what was listed on the Pull Request web page.)
That is basically using Xcode as your git client, which is possible and might serve your purposes well enough. However, I recommend to use either the git command line client (most flexible and powerful, but also more difficult to learn) or one of the git GUI clients (SmartGit, SourceTree, etc.). In any case you should head over to the official git homepage and read the first chapters of the git documentation. These should give you a good introduction and cover the basic concepts of git.

Hint: Mat and dbenage-cx are on Linux, things work a bit differently there, mostly because there is no SDK for Linux (not needed on that platform). On Mac, once you've set up your development environment with the SDK you already have a cloned repo and checked out master branch (the bootstrap.sh script does that for you). So you can skip the instructions about cloning the repo and setting up your local copy.

There is also the (somewhat lengthy) The Git/GitHub Questions, Answers and Howto Thread. I know it looks a bit much, but digging through it might also help you along.

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: XCode and local GitHub branches

#15 Post by adrian_broher »

dbenage-cx wrote:Outside of not needing to setup and sync a remote, are there other benefits to this?
No, you just have a nicer interface to access GitHub (e.g. hub checkout <some github web UI url pointing to a PR, branch, commit>) and it does add some additional features like `list issues/PR`, `create a PR` and other things you can also do via the Web UI. For a full feature you can take a look into the man page. I personally don't use it, because I already had some git alias commands set up for git related tasks and github related task I handle via the web UI, but for someone else it might be helpful.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

Post Reply