def create_diff_and_revision(self, diff_file, project_part): callsign_mappings = phab_diff.get_callsign_mapping() group_number = submitted_diffs.get_diff_group_number( diff_file, callsign_mappings=callsign_mappings) if not group_number: print('Error: Could not determine group number from filename: %s' % diff_file) return -1 project_name = group_translator.build_project_name( group_num=group_number, project_part=project_part, is_marking_group=False) marking_project_name = group_translator.build_project_name( group_num=group_number, project_part=project_part, is_marking_group=True) # this code will only run if we know a group to which we should assign this diff to marking_project_phid = phab_project.get_phid_from_name( marking_project_name) if not marking_project_phid: print("Error: could not find project PHID for diff: %s" % diff_file) return -1 # this code will only run if we have a valid phid for the project diff_id = self.create_diff_from_file(diff_file) if diff_id < 0: print('Error: Could not create differential with file: %s' % diff_file) return -1 # this code will only run if we successfully created a diff revision_id = phab_diff.create_revision(diff_id=diff_id, title=project_name) if not revision_id: print('Error: Unable to create revision for diff file: %s' % diff_file) # this code will only run if we have successfully created a diff & revision policy_phid = phab_policy.create_project_policy([marking_project_phid]) if not policy_phid: print("Error: unable to create policy") return -1 # this code will only run if we have a policy to add to our new revision phab_diff.set_revision_policy(revision_id=revision_id, view_policy=policy_phid, edit_policy=policy_phid) revision_phid = phab_diff.get_phid_from_id(revision_id) if not revision_phid: print("Error: unable to obtain phid for revision") return -1 # this code will only run if we know our marking project and revision phids self.assign_project_users_to_diff_revision_as_reviewers( revision_phid, marking_project_phid) print("Success for project: %s" % (project_name)) '''
def create_diff_and_revision(self, diff_file, project_part): callsign_mappings = phab_diff.get_callsign_mapping() group_number = submitted_diffs.get_diff_group_number(diff_file, callsign_mappings=callsign_mappings) if not group_number: print('Error: Could not determine group number from filename: %s' % diff_file) return -1 project_name = group_translator.build_project_name( group_num=group_number, project_part=project_part, is_marking_group=False ) marking_project_name = group_translator.build_project_name( group_num=group_number, project_part=project_part, is_marking_group=True ) # this code will only run if we know a group to which we should assign this diff to marking_project_phid = phab_project.get_phid_from_name(marking_project_name) if not marking_project_phid: print("Error: could not find project PHID for diff: %s" % diff_file) return -1 # this code will only run if we have a valid phid for the project diff_id = self.create_diff_from_file(diff_file) if diff_id < 0: print('Error: Could not create differential with file: %s' % diff_file) return -1 # this code will only run if we successfully created a diff revision_id = phab_diff.create_revision( diff_id=diff_id, title=project_name ) if not revision_id: print('Error: Unable to create revision for diff file: %s' % diff_file) # this code will only run if we have successfully created a diff & revision policy_phid = phab_policy.create_project_policy([marking_project_phid]) if not policy_phid: print("Error: unable to create policy") return -1 # this code will only run if we have a policy to add to our new revision phab_diff.set_revision_policy( revision_id=revision_id, view_policy=policy_phid, edit_policy=policy_phid ) revision_phid = phab_diff.get_phid_from_id(revision_id) if not revision_phid: print("Error: unable to obtain phid for revision") return -1 # this code will only run if we know our marking project and revision phids self.assign_project_users_to_diff_revision_as_reviewers(revision_phid , marking_project_phid) print("Success for project: %s" % (project_name)) '''
if project_number == part: # note: if your student groups differ from marking groups, you can use the commented out line below # make sure you change the number (1) to the student group you want to use. student_project_name = group_translator.build_project_name( group_number, 1, False) # student_project_name = group_translator.build_project_name(group_number, project_number, False) marking_project_name = group_translator.build_project_name( group_number, project_number, True) student_project_phid = phab_project.get_phid_from_name( student_project_name) marking_project_phid = phab_project.get_phid_from_name( marking_project_name) if marking_project_phid is not None and student_project_phid is not None: policy = phab_policy.create_project_policy( [student_project_phid, marking_project_phid]) phab_diff.set_revision_policy(diff['id'], policy, policy) print( 'Diff %s was assigned policy %s (View,Edit) allowing access from student group %s and marking group %s' % ( diff['title'], policy, student_project_name, marking_project_name, )) else: print( 'ERROR: Unable to determine student and/or marking groups for %s' % diff['title']) else: # these diff are not belong to us (probably from a different project) pass
part = int(sys.argv[2]) all_diffs = phab_diff.get_all_diffs() for diff in all_diffs: group_number = group_translator.get_group_number_from_project_name(diff['title']) project_number = group_translator.get_project_number_from_project_name(diff['title']) if project_number == part: # note: if your student groups differ from marking groups, you can use the commented out line below # make sure you change the number (1) to the student group you want to use. student_project_name = group_translator.build_project_name(group_number, 1, False) # student_project_name = group_translator.build_project_name(group_number, project_number, False) marking_project_name = group_translator.build_project_name(group_number, project_number, True) student_project_phid = phab_project.get_phid_from_name(student_project_name) marking_project_phid = phab_project.get_phid_from_name(marking_project_name) if marking_project_phid is not None and student_project_phid is not None: policy = phab_policy.create_project_policy([student_project_phid, marking_project_phid]) phab_diff.set_revision_policy(diff['id'], policy, policy) print('Diff %s was assigned policy %s (View,Edit) allowing access from student group %s and marking group %s' % ( diff['title'], policy, student_project_name, marking_project_name, )) else: print('ERROR: Unable to determine student and/or marking groups for %s' % diff['title']) else: # these diff are not belong to us (probably from a different project) pass thanks() elif arg_task == 'generate-diffs':