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

Method _record_commit

setupbase.py:183–210  ·  view source on GitHub ↗
(self, base_dir)

Source from the content-addressed store, hash-verified

181 self._record_commit(base_dir)
182
183 def _record_commit(self, base_dir):
184 import subprocess
185 proc = subprocess.Popen('git rev-parse --short HEAD',
186 stdout=subprocess.PIPE,
187 stderr=subprocess.PIPE,
188 shell=True)
189 repo_commit, _ = proc.communicate()
190 repo_commit = repo_commit.strip().decode("ascii")
191
192 out_pth = Path(base_dir) / pkg_dir / "utils" / "_sysinfo.py"
193 if out_pth.is_file() and not repo_commit:
194 # nothing to write, don't clobber
195 return
196
197 print(f"writing git commit '{repo_commit}' to {out_pth}")
198
199 # remove to avoid overwriting original via hard link
200 try:
201 out_pth.unlink()
202 except FileNotFoundError:
203 pass
204 with out_pth.open("w", encoding="utf-8") as out_file:
205 out_file.writelines(
206 [
207 "# GENERATED BY setup.py\n",
208 f'commit = "{repo_commit}"\n',
209 ]
210 )
211
212 return MyBuildPy

Callers 2

runMethod · 0.95
make_release_treeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected