MCPcopy Create free account
hub / github.com/ipython/ipython / _record_commit

Method _record_commit

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

Source from the content-addressed store, hash-verified

378 self._record_commit(base_dir)
379
380 def _record_commit(self, base_dir):
381 import subprocess
382 proc = subprocess.Popen('git rev-parse --short HEAD',
383 stdout=subprocess.PIPE,
384 stderr=subprocess.PIPE,
385 shell=True)
386 repo_commit, _ = proc.communicate()
387 repo_commit = repo_commit.strip().decode("ascii")
388
389 out_pth = pjoin(base_dir, pkg_dir, 'utils', '_sysinfo.py')
390 if os.path.isfile(out_pth) and not repo_commit:
391 # nothing to write, don't clobber
392 return
393
394 print("writing git commit '%s' to %s" % (repo_commit, out_pth))
395
396 # remove to avoid overwriting original via hard link
397 try:
398 os.remove(out_pth)
399 except (IOError, OSError):
400 pass
401 with open(out_pth, 'w') as out_file:
402 out_file.writelines([
403 '# GENERATED BY setup.py\n',
404 'commit = u"%s"\n' % repo_commit,
405 ])
406 return MyBuildPy
407

Callers 2

runMethod · 0.95
make_release_treeMethod · 0.95

Calls 2

writelinesMethod · 0.80
removeMethod · 0.45

Tested by

no test coverage detected