Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode bot: git submodules not initialized

I'm trying to set up an Xcode bot with OSX server. After configuring the git repository and creating a bot, I run integrate. It fails because the repository is checked out only partially. More precisely: Of the 6 submodules configured, only 3 are initialized and checked out.

didi@mac:/Library/Server/Xcode/Data/BotRuns/Cache/c5fda8f4-4d25-4d25-c18a-eb0b16a06692/source$ git submodule status
+c6e8420aec4147641fb1ca12d9f1d31bdd804e77 libs/asi-http-request (v1.7-320-gc6e8420)
-ae64a38766b42f236bb94f0e661cddb829f9ac43 libs/kraken
-7da02b323636bbaa0bbbf5b4eb229fcc07b1e14a libs/route-me
 152f9ee5576e710705a49032253d7d5af5366f9c libs/routing (152f9ee)
 347aaf74fe0c6388785095efdbf6397851514b7f libs/rtlabel (1.0-32-g347aaf7)
-562cf6b1c879f03546f5184e012cea15c4f159db libs/skmaps

(- means not initialized)

Looking at the bot log, it seems to just ignore the missing submodules in the submodule initialize part:

...
Checking connectivity... done
Submodule 'libs/asi-http-request' (https://github.com/BikeCityGuide/asi-http-request.git) registered for path 'libs/asi-http-request'
Submodule 'libs/routing' (ssh://[email protected]/var/repos/librouting.git) registered for path 'libs/routing'
Submodule 'libs/rtlabel' (https://github.com/BikeCityGuide/RTLabel.git) registered for path 'libs/rtlabel'
Cloning into 'libs/asi-http-request'...
...

No error message here or anywhere else. No single mention of e.g. "kraken" (name of a missing submodule) anywhere in the logs.

When checking out manually (clone, submodule init, submodule update), all submodules are initialized.

.gitmodules looks like this:

$ cat .gitmodules 
[submodule "libs/asi-http-request"]
    path = libs/asi-http-request
    url = https://github.com/BikeCityGuide/asi-http-request.git
[submodule "libs/rtlabel"]
    path = libs/rtlabel
    url = https://github.com/BikeCityGuide/RTLabel.git
[submodule "libs/routing"]
    path = libs/routing
    url = ../librouting.git
[submodule "libs/kraken"]
    path = libs/kraken
    url = ../kraken_ios.git
[submodule "libs/route-me"]
    path = libs/route-me
    url = ../route-me.git
[submodule "libs/skmaps"]
    path = libs/skmaps
    url = ../skmaps.git

The base repository and the 4 submodule repositories referenced with relative URL all need ssh authentication. The user set up in OSX server has access to all of them. The log of the bot contains no trace of trying to pull the missing submodules.

I can manually fix the local repository, but I'd like not to have the same issue again with new projects and new submodules added.

git version 1.8.4.2

I'm out of ideas.

like image 871
didi_X8 Avatar asked Jan 09 '14 10:01

didi_X8


People also ask

How do I initialize a git submodule?

If you already cloned the project and forgot --recurse-submodules , you can combine the git submodule init and git submodule update steps by running git submodule update --init . To also initialize, fetch and checkout any nested submodules, you can use the foolproof git submodule update --init --recursive .

How do submodules work in Git?

A git submodule is a record within a host git repository that points to a specific commit in another external repository. Submodules are very static and only track specific commits. Submodules do not track git refs or branches and are not automatically updated when the host repository is updated.

What is git submodule sync?

git submodule sync synchronizes all submodules while git submodule sync -- A synchronizes submodule "A" only. If --recursive is specified, this command will recurse into the registered submodules, and sync any nested submodules within.

Where is the .gitmodules file?

The . gitmodules file, located in the top-level directory of a Git working tree, is a text file with a syntax matching the requirements of git-config[1].


2 Answers

On Xcode 6.1.1 and OS X Server 4.0, it looks like they fixed the submodules with detached HEAD issue, but there are still some bugs. One of my project has one its submodules being completely ignored by Xcode Server so the app fails to build:

$ git submodule
 8a88bc41c9dc0f57c921d82bc4e7b93e1c4cbf7a InAppStore (heads/master)
 e4203f9f61d2546868c1274da5c7a0c56b87a737 Libraries (heads/master)  <--- IGNORED
 01902f255e6c3d90f0db41cb62dd2934098b98dd MixpanelTracker (heads/master)
 e2bee59accd817d50dff881a42c9e9afe307226f XLFacility (1.4.1-5-ge2bee59)

The fix for me was to add a pre-integration script trigger as such:

cd "$XCS_SOURCE_DIR/{YOUR_APP_REPO_NAME_WITHOUT_DOT_GIT_SUFFIX}"
git submodule update --init --recursive

At this point things were building although there were non-fatal warnings about the checkout not being clean or something like that. They went away when I changed to the bot's configuration to have "Cleaning" set to "Always".

like image 184
Pol Avatar answered Sep 20 '22 13:09

Pol


In Xcode 9 server, submodules are not initialized if none of the files of the submodules is referenced by one of the Xcode projects in the workspace.

This may happen, for instance, when you include a header file from a submodule that is not part of your code and therefore you added it to the "headers search paths" (c/c++) instead of adding it to the project.

A possible workaround is to add at least one file from the submodule to the Xcode project. It can even be a Readme.md file. This is easier than checking out submodules using a custom script because it relies on Xcode Server to store your GIT credentials.

like image 31
Yoav Avatar answered Sep 18 '22 13:09

Yoav