MCPcopy Index your code
hub / github.com/ipython/ipython / pkg_commit_hash

Function pkg_commit_hash

IPython/utils/sysinfo.py:32–67  ·  view source on GitHub ↗

Get short form of commit hash given directory `pkg_path` We get the commit hash from (in order of preference): * IPython.utils._sysinfo.commit * git output, if we are in a git repository If these fail, we return a not-found placeholder tuple Parameters ---------- pkg_

(pkg_path: str)

Source from the content-addressed store, hash-verified

30#-----------------------------------------------------------------------------
31
32def pkg_commit_hash(pkg_path: str) -> tuple[str, str]:
33 """Get short form of commit hash given directory `pkg_path`
34
35 We get the commit hash from (in order of preference):
36
37 * IPython.utils._sysinfo.commit
38 * git output, if we are in a git repository
39
40 If these fail, we return a not-found placeholder tuple
41
42 Parameters
43 ----------
44 pkg_path : str
45 directory containing package
46 only used for getting commit from active repo
47
48 Returns
49 -------
50 hash_from : str
51 Where we got the hash from - description
52 hash_str : str
53 short form of hash
54 """
55 # Try and get commit from written commit text file
56 if _sysinfo.commit:
57 return "installation", _sysinfo.commit
58
59 # maybe we are in a repository
60 proc = subprocess.Popen('git rev-parse --short HEAD'.split(' '),
61 stdout=subprocess.PIPE,
62 stderr=subprocess.PIPE,
63 cwd=pkg_path)
64 repo_commit, _ = proc.communicate()
65 if repo_commit:
66 return 'repository', repo_commit.strip().decode('ascii')
67 return '(none found)', '<not found>'
68
69
70def pkg_info(pkg_path: str) -> dict:

Callers 1

pkg_infoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…