Implemented some safeguards that enable only commits of untracked metadata review files
This commit is contained in:
@@ -97,21 +97,28 @@ def first_initialize_metadata_review(hdf5_file_path, reviewer_attrs):
|
|||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
#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:
|
with open(os.path.join(review_yaml_file_path_tail+"-review_status"+".txt"),'w') as f:
|
||||||
f.write('under review')
|
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)
|
status = subprocess.run(status_command,capture_output=True,text=True,check=True)
|
||||||
untracked_files_for_review = []
|
untracked_files = []
|
||||||
for line in status.stdout.splitlines():
|
for line in status.stdout.splitlines():
|
||||||
if 'review/' in line.decode('utf8'):
|
#tmp = line.decode("utf-8")
|
||||||
untracked_files_for_review.append(line)
|
#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)
|
if untracked_files:
|
||||||
|
result = subprocess.run(add_command(untracked_files),capture_output=True,check=True)
|
||||||
message = 'Initialized metadata review.'
|
message = 'Initialized metadata review.'
|
||||||
commit_output = subprocess.run(commit_command(message),capture_output=True,check=True)
|
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