MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / clone_cppcheck

Function clone_cppcheck

tools/donate_cpu_lib.py:103–119  ·  view source on GitHub ↗
(repo_path, migrate_from_path)

Source from the content-addressed store, hash-verified

101
102
103def clone_cppcheck(repo_path, migrate_from_path):
104 repo_git_dir = os.path.join(repo_path, '.git')
105 if os.path.exists(repo_git_dir):
106 return
107 # Attempt to migrate clone directory used prior to 1.3.17
108 if os.path.exists(migrate_from_path):
109 os.rename(migrate_from_path, repo_path)
110 else:
111 # A shallow git clone (depth = 1) is enough for building and scanning.
112 # Do not checkout until fetch_cppcheck_version.
113 subprocess.check_call(['git', 'clone', '--depth=1', '--no-checkout', CPPCHECK_REPO_URL, repo_path])
114 # Checkout an empty branch to allow "git worktree add" for main later on
115 try:
116 # git >= 2.27
117 subprocess.check_call(['git', 'switch', '--orphan', 'empty'], cwd=repo_path)
118 except subprocess.CalledProcessError:
119 subprocess.check_call(['git', 'checkout', '--orphan', 'empty'], cwd=repo_path)
120
121
122def checkout_cppcheck_version(repo_path, version, cppcheck_path):

Callers

nothing calls this directly

Calls 2

joinMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected