Xcode Bots do not update git submodules to specified commit - xcode

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.
Parent repo uses submodule v1.0.
Parent repo updates submodule to v2.0 and commits subproject commit to github.
The "on commit" Xcode Bot is run for the new commit automatically.
Parent app is uploaded to TestFlight.
TestFlight build contains the correct v2.0 submodule commit (the last commit to parent repo).
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.

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.

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.

Related

how to find out which git-branch a dependency in go.mod belongs to by command-line?

I want to write a shell program to check whether all go module dependencies in my project are on newest master version in their repositories. In particular, I want to know which branch each module is on. There is a file "go.mod" containing each dependency listed as {module}-{commit time}-{commit ID}. How can I get their git-branch name from SHA-1(commit id) or other message by shell program.
I have tried go list -m -u all, only showing the newest edition if the dependency is not up-to-date. etc. git.xxx.com/project v0.0.0-20191119034146-e894bf51bdcd [v0.0.0-20200609070643-fd412b12b811]. Without cloning the repos, can go module tools resolve this quetion?
I couldn't figure out how to find which branch the current dependency belongs to using only go tools. But there is a way to find which branch the commit is on using git.
git clone <repo-url> && cd <repo> && git branch -a --contains <commit>
Reference: Finding what branch a Git commit came from

Why doesn't Git track files modified in Xcode?

I'm using Git on the terminal to commit changes & push them to a remote repo.
Git can recognize when I create a file or modify a file via VS Code. However, when I work on my files on Xcode and save them, Git doesn't track any changes. It tells me:
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
What's the problem and how can I fix it?

Xcode 7 / Git - Working with Workspaces

How do you work with Xcode workspaces in git? Until now, I've successfully added several projects to a workspace with each individual project having its own git. Each project then gets pushed to the remote server (github).
Works great, but the problem comes when checking out the entire workspace. I need to check out each project individually, making sure they have the same relative paths as they had on the original computer that made the push. Its tricky and prone to errors.
Is there another way?
Having faced the same problem myself, I used git submodules for the projects I wanted to add them to the main project.
Adding submodules:
$git submodule add https://github.com/chaconinc/DbConnector
$git submodule init
$git submodule update
you can update to changes on your remote server:
$git submodules update --remote
more info Here

Pull specific revision from master branch?

Im very new to Git and what I want to do with git within xcode is pull an older revision of my master (not commandline). Is this possible? I've looked in repositories under the organizer and i see all my commits there but i cant seem to load in one of them.
You can't go back to an earlier version of a repository from Xcode in Xcode 4. Older versions of Xcode allow you to go back to an earlier version of a repository, but older versions of Xcode lack git support.
I think that if you have cloned/pushed your repo all the stuff you need is on your local drive.
If you want to see how code looks in specific commit, do
git checkout branch_name
or
git checkout 14646bf1a76d08cbda99317c4faa8de0072d6975
where branch_name can be alias for checksum used by git, (like master or origin/master), if you want to list your branch checksums you can do that by
git log
or if you want it in GUI use qgit gitg or my favourite tig, or whatever you'll find to list your commits

Git repo for framework inside local git project in Xcode 4

I have an iOS project in Xcode 4, that is using Git. Now I want to add the MKStoreKit framework to my project. It is already under version control using Git and a public repo. I'd like to include it in my project, and allow my project's git version control to do version control of the currently pulled version of MKStoreKit, while maintaining the ability to clone any updated MKStoreKit code with standard git ease. I see that a git submodule or subtree is probably what I need, but it seems like a real PITA. Is there not a simpler way?
So far any external code I add to my project I clone to a temp directory, then copy the individual files into my project. This feels like a kludgy way to do things.
Check out the submodules section of the Git book. They're not really all that bad.
If you have a git repository, and you want to add another repository as a subdirectory, you can do this:
git submodule add git://github.com/MugunthKumar/MKStoreKit.git mstorekit
Now you have a directory "mstorekit" inside your project that is actually the MStoreKit repository. If someone clones your repository, they'll start with an empty "mstorekit" directory. Running:
git submodule init
git submodule update
Will clone the MStoreKit repository. They'll end up with the HEAD of the MStoreKit repository at the same commit as the one checked in to your repository.
Updating MStoreKit would look like this:
cd mstorekit
git pull origin master
cd ..
git ci -m 'updated mstorekit to latest version'
There are some alternatives out there, including git-subtree, which I saw mentioned recently around here. I have no experience with it (whereas I've been reasonably happy working with submodules).

Resources