Refactored comment lines.

This commit is contained in:
2024-04-04 12:58:17 +02:00
parent 2d5fecfb34
commit dd1f1245e3

View File

@ -50,7 +50,8 @@ def checkout_review_branch(branch_name):
#else:
# branch = repo_obj.branches[branch_name]
#repo_obj.checkout(branch)
current_branch_command = ['git','branch','--show-current']
status_command = ['git','status']
add_command = lambda add_list: ['git','add'] + add_list
commit_command = lambda message: ['git','commit','-m', message]
@ -82,7 +83,7 @@ def first_initialize_metadata_review(hdf5_file_path, reviewer_attrs):
#checkout_review_branch(branch_name)
# Check you are working at the right branch
current_branch_command = ['git','branch','--show-current']
curr_branch = subprocess.run(current_branch_command,capture_output=True,text=True,check=True)
if not branch_name in curr_branch.stdout:
@ -150,43 +151,31 @@ def second_submit_metadata_review(review_yaml_file_path, reviewer_attrs):
# TODO: replace with subprocess + git
#checkout_review_branch(repo_obj, branch_name)
current_branch_command = ['git','branch','--show-current']
# Check you are working at the right branch
curr_branch = subprocess.run(current_branch_command,capture_output=True,text=True,check=True)
if not branch_name in curr_branch.stdout:
raise ValueError('Make sure you are located at branch' + branch_name + '. Try to Excecute Cell with Step 1 first. ')
#if any([status in get_review_status(filename_path) for status in ['under review','submitted']]):
# filename_path_tail, filename_path_head = os.path.split(filename_path)
# filename, ext = os.path.splitext(filename_path_head)
# # TODO:
##
#push_command = lambda repository,refspec: ['git','push',repository,refspec]
raise ValueError('Please checkout ' + branch_name + ' via Git Bash before submitting metadata review files. ')
# Collect modified review files
status = subprocess.run(status_command,capture_output=True,check=True)
files_to_add_list = []
modified_files = []
for line in status.stdout.splitlines():
# conver line from bytes to str
tmp = line.decode("utf-8")
if 'modified' in tmp and review_yaml_file_path in tmp:
files_to_add_list.append(tmp.split()[1])
##
modified_files.append(tmp.split()[1])
# Stage modified files and commit them to local repository
review_yaml_file_path_tail, review_yaml_file_path_head = os.path.split(review_yaml_file_path)
filename, ext = os.path.splitext(review_yaml_file_path_head)
if files_to_add_list:
if modified_files:
review_status_file_path = os.path.join("review/",filename+"-review_status"+TXT_EXT)
with open(review_status_file_path,'a') as f:
f.write('\nsubmitted')
files_to_add_list.append(review_status_file_path)
modified_files.append(review_status_file_path)
result = subprocess.run(add_command(files_to_add_list),capture_output=True,check=True)
result = subprocess.run(add_command(modified_files),capture_output=True,check=True)
message = 'Submitted metadata review.'
commit_output = subprocess.run(commit_command(message),capture_output=True,check=True)
@ -196,20 +185,6 @@ def second_submit_metadata_review(review_yaml_file_path, reviewer_attrs):
print('Nothing to commit.')
#status_dict = repo_obj.status()
#for filepath, file_status in status_dict.items():
# Identify keys associated to review files and stage them
# if ('review/'+filename in filepath) and (file_status == pygit.GIT_STATUS_WT_MODIFIED):
# Stage changes
# repo_obj.index.add(filepath)
#author = config_file.author #default_signature
#committer = config_file.committer
#message = "Submitted metadata review."
#tree = repo_obj.index.write_tree()
#oid = repo_obj.create_commit('HEAD', author, committer, message, tree, [repo_obj.head.peel().oid])
def third_complete_metadata_review(reviewer_attrs):