pkamb
pkamb

Reputation: 34983

Xcode Bots do not update git submodules to specified commit

My Xcode Bot is using an outdated version of my repo's submodules.

It builds old submodule code despite the submodule being updated to a new version in the commit history of the parent app.

  1. Parent repo uses submodule v1.0.
  2. Parent repo updates submodule to v2.0 and commits subproject commit to github.
  3. The "on commit" Xcode Bot is run for the new commit automatically.
  4. Parent app is uploaded to TestFlight.
  5. TestFlight build contains the correct v2.0 submodule commit (the last commit to parent repo).
  6. However the TestFlight build contains the outdated submodule v1.0 code.

I thought I was going crazy when my bugs were reproducible on the TestFlight build despite being "fixed" in the submodule and local builds.

It turns out Xcode Bots do not properly pull the specified submodule commit.

Upvotes: 3

Views: 1264

Answers (2)

pkamb
pkamb

Reputation: 34983

As of Xcode 6, Xcode Bots are not guaranteed to update the repo's submodules to the specified commit.

You will need to manually update the submodules prior to the Xcode Bot's build:

git submodule update --init --recursive

To make this easier I've added updateGitSubmodules to the cavejohnson Xcode Bot scripting tool. Add the following to your Before Integration Run Script phase to update submodules automatically:

Before Integration > Run Script:

#!/bin/bash
PATH=/Library/Frameworks/Python.framework/Versions/3.4/bin:$PATH

cavejohnson updateGitSubmodules

Finally, we've opened an ticket to explore how this behavior can be fixed upstream.

Upvotes: 1

Accatyyc
Accatyyc

Reputation: 5828

A simpler solution to this problem which doesn't require the server having credecentials for your git remotes - add this as a pre-integration script for your bot:

#!/bin/sh
# Enumerates each submodule to check out the desired commit.
# Needed because Xcode bots for some reason prefers to check out
# the branch head, which may result in the wrong commit.
cd "$XCS_PRIMARY_REPO_DIR"
git submodule foreach --recursive 'git checkout $sha1'

It recursively enumerates your submodules and checks out the commit expected by the parent repo.

Upvotes: 2

Related Questions