1

I'm trying to programatically figure out the git hash of the tag/branch/commit or whatever is used for a dependency of my project in order to provide more information for debugging, provided the depenency is stored in a git repo. Any ideas? I would rather not clone the dependency again.

asked Aug 5, 2015 at 8:23

1 Answer 1

2

This will depending on how the Pod has been installed. If you've installed a Pod from an external source, such as if you use the following in your Podfile:

pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git'

You can find the checkout options used within the Podfile.lock, which is a machine readable YAML file:

CHECKOUT OPTIONS:
 AFNetworking:
 :commit: ba7b6e541fd18bdf48da6d4845670e3e6b990637
 :git: https://github.com/AFNetworking/AFNetworking.git

If instead, you are using a spec repository, you would need to consult the podspec used for the Pod, which will be found in the local checkout of the pod spec repository used (if this is the master spec repository, at ~/.cocoapods/repos/master/). The pod spec will contain the required checkout information. For example, if you are using AFNetworking 2.5.2 from the master spec repository you can find the checkout information in the necessary podspec:

$ grep -A 3 '"source"' ~/.cocoapods/repos/master/Specs/AFNetworking/2.5.2/AFNetworking.podspec.json
 "source": {
 "git": "https://github.com/AFNetworking/AFNetworking.git",
 "tag": "2.5.2",
 "submodules": true
answered Aug 5, 2015 at 11:26
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much for the quick reply! I'm using a spec repository, so i can't get at the :commit: entry and the source information in a spec typically don't include git hashes. Do you know if cocoapods does a git clone on it's dependencies (if they are git based)? Or does it check out the sources in a different way. I tried to look myself but i'm quite new to ruby and got lost in the source code.
CocoaPods would do a git clone on the information from the spec, normally this would be a git tag so it would do a clone for that tag. You can find the code to determine the git arguments at github.com/CocoaPods/cocoapods-downloader/blob/master/lib/…

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.