Implemented some safeguards that enable only commits of untracked metadata review files
This commit is contained in:
@@ -95,23 +95,30 @@ def first_initialize_metadata_review(hdf5_file_path, reviewer_attrs):
|
||||
if not os.path.exists(review_yaml_file_path):
|
||||
review_yaml_file_path = utils.make_file_copy(os.path.join(hdf5_file_path_tail,filename+YAML_EXT), 'review')
|
||||
|
||||
review_yaml_file_path_tail, ext = os.path.splitext(review_yaml_file_path)
|
||||
review_yaml_file_path_tail, ext = os.path.splitext(review_yaml_file_path)
|
||||
|
||||
with open(os.path.join(review_yaml_file_path_tail+"-review_status"+".txt"),'w') as f:
|
||||
f.write('under review')
|
||||
#if not os.path.exists(os.path.join(review_yaml_file_path_tail+"-review_status"+".txt")):
|
||||
with open(os.path.join(review_yaml_file_path_tail+"-review_status"+".txt"),'w') as f:
|
||||
f.write('under review')
|
||||
|
||||
# Stage review files and commit them to local repository
|
||||
# Stage untracked review files and commit them to local repository
|
||||
status = subprocess.run(status_command,capture_output=True,text=True,check=True)
|
||||
untracked_files_for_review = []
|
||||
untracked_files = []
|
||||
for line in status.stdout.splitlines():
|
||||
if 'review/' in line.decode('utf8'):
|
||||
untracked_files_for_review.append(line)
|
||||
#tmp = line.decode("utf-8")
|
||||
#modified_files.append(tmp.split()[1])
|
||||
if 'review/' in line and not 'modified' in line: # untracked files
|
||||
untracked_files.append(line.strip())
|
||||
|
||||
result = subprocess.run(add_command(untracked_files_for_review),capture_output=True,check=True)
|
||||
message = 'Initialized metadata review.'
|
||||
commit_output = subprocess.run(commit_command(message),capture_output=True,check=True)
|
||||
if untracked_files:
|
||||
result = subprocess.run(add_command(untracked_files),capture_output=True,check=True)
|
||||
message = 'Initialized metadata review.'
|
||||
commit_output = subprocess.run(commit_command(message),capture_output=True,check=True)
|
||||
|
||||
print(commit_output.stdout)
|
||||
for line in commit_output.stdout.splitlines():
|
||||
print(line.decode('utf-8'))
|
||||
else:
|
||||
print('This action will not have any effect because metadata review process has been already initialized.')
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user