Created
January 8, 2016 16:48
-
-
Save thomasjpfan/40c19de0e27f070a8482 to your computer and use it in GitHub Desktop.
Workaround for Carthage - place in .git/hooks/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import hashlib | |
import subprocess | |
import shutil | |
from pathlib import Path | |
def main(): | |
carthage_build = Path('./Carthage/Build') | |
cartfile_build = Path('./Carthage/Build/Cartfile.resolved') | |
cartfile = Path('./Cartfile.resolved') | |
same_resolved_file = md5file(cartfile_build) == md5file(cartfile) | |
if not (carthage_build.exists() and same_resolved_file): | |
subprocess.run("carthage build --platform iOS --no-use-binaries".split()) | |
shutil.copyfile(str(cartfile.absolute()), str(cartfile_build.absolute())) | |
def md5file(p): | |
try: | |
return hashlib.sha224(p.read_bytes()).hexdigest() | |
except FileNotFoundError: | |
return p | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment