Skip to content

Commit e0073ea

Browse files
committed
Added support for saving git repo info.
1 parent c3b7988 commit e0073ea

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

labscript/labscript.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,6 +2206,14 @@ def save_labscripts(hdf5_file):
22062206
info, err = process.communicate()
22072207
if info or err:
22082208
hdf5_file[save_path].attrs['hg ' + str(command[0])] = info.decode('utf-8') + '\n' + err.decode('utf-8')
2209+
if compiler.save_git_info:
2210+
module_filename = os.path.split(path)[1]
2211+
git_commands = [['branch', '--show-current'], ['rev-parse', '--verify', 'HEAD'], ['diff', 'HEAD', module_filename]]
2212+
for command in git_commands:
2213+
process = subprocess.Popen(['git'] + command, cwd=os.path.split(path)[0], stdout=subprocess.PIPE,
2214+
stderr=subprocess.PIPE, startupinfo=startupinfo)
2215+
info, err = process.communicate()
2216+
hdf5_file[save_path].attrs['git ' + str(command[0])] = info.decode('utf-8') + '\n' + err.decode('utf-8')
22092217
except ImportError:
22102218
pass
22112219
except WindowsError if os.name == 'nt' else None:
@@ -2540,6 +2548,7 @@ def labscript_cleanup():
25402548
compiler.time_markers = {}
25412549
compiler._PrimaryBLACS = None
25422550
compiler.save_hg_info = True
2551+
compiler.save_git_info = True
25432552
compiler.shot_properties = {}
25442553

25452554
class compiler(object):
@@ -2560,6 +2569,7 @@ class compiler(object):
25602569
time_markers = {}
25612570
_PrimaryBLACS = None
25622571
save_hg_info = True
2572+
save_git_info = True
25632573
shot_properties = {}
25642574

25652575
# safety measure in case cleanup is called before init

0 commit comments

Comments
 (0)