MCPcopy
hub / github.com/emscripten-core/emsdk / git_pull

Function git_pull

emsdk.py:812–845  ·  view source on GitHub ↗
(repo_path, branch_or_tag, remote_name='origin')

Source from the content-addressed store, hash-verified

810
811
812def git_pull(repo_path, branch_or_tag, remote_name='origin'):
813 debug_print(f'git_pull(repo_path={repo_path}, branch/tag={branch_or_tag}, remote_name={remote_name})')
814 ret = run([GIT(), 'fetch', '--quiet', remote_name], repo_path)
815 if ret != 0:
816 return False
817 try:
818 print(f"Fetching latest changes to the branch/tag '{branch_or_tag}' for '{repo_path}'...")
819 ret = run([GIT(), 'fetch', '--quiet', remote_name], repo_path)
820 if ret != 0:
821 return False
822 # Test if branch_or_tag is a branch, or if it is a tag that needs to be updated
823 target_is_tag = run([GIT(), 'symbolic-ref', '-q', 'HEAD'], repo_path, quiet=True)
824
825 if target_is_tag:
826 ret = run([GIT(), 'checkout', '--recurse-submodules', '--quiet', branch_or_tag], repo_path)
827 else:
828 local_branch_prefix = (remote_name + '_') if remote_name != 'origin' else ''
829 ret = run([GIT(), 'checkout', '--recurse-submodules', '--quiet', '-B', local_branch_prefix + branch_or_tag,
830 '--track', remote_name + '/' + branch_or_tag], repo_path)
831 if ret != 0:
832 return False
833 if not target_is_tag:
834 # update branch to latest (not needed for tags)
835 # this line assumes that the user has not gone and made local changes to the repo
836 ret = run([GIT(), 'merge', '--ff-only', remote_name + '/' + branch_or_tag], repo_path)
837 if ret != 0:
838 return False
839 run([GIT(), 'submodule', 'update', '--init'], repo_path, quiet=True)
840 except Exception:
841 errlog('git operation failed!')
842 return False
843 print(f"Successfully updated and checked out branch/tag '{branch_or_tag}' on repository '{repo_path}'")
844 print("Current repository version: " + git_repo_version(repo_path))
845 return True
846
847
848def git_clone_checkout_and_pull(url, dstpath, branch, override_remote_name='origin'):

Callers 1

Calls 5

debug_printFunction · 0.85
runFunction · 0.85
GITFunction · 0.85
errlogFunction · 0.85
git_repo_versionFunction · 0.85

Tested by

no test coverage detected