app/jobs/assignment_repo/create_github_repository_job.rb
# Creates an AssignmentRepo with an associated GitHub repo
# If creation fails, it deletes the GitHub repo
#
# rubocop:disable MethodLength
# rubocop:disable AbcSize
Creates an AssignmentRepo with an associated GitHub repo
If creation fails, it deletes the GitHub repo


Creates an AssignmentRepo with an associated GitHub repo If creation fails it deletes the GitHub repo
def create_assignment_repo(assignment, user)
      creator = Creator.new(assignment: assignment, user: user)
      creator.verify_organization_has_private_repos_available!
      github_repository = creator.create_github_repository!
      assignment_repo = assignment.assignment_repos.build(
        github_repo_id: github_repository.id,
        github_global_relay_id: github_repository.node_id,
        user: user
      )
      creator.add_user_to_repository!(assignment_repo.github_repo_id)
      creator.push_starter_code!(assignment_repo.github_repo_id) if assignment.starter_code?
      assignment_repo.save!
      assignment_repo
    rescue ActiveRecord::RecordInvalid => err
      creator.delete_github_repository(assignment_repo.try(:github_repo_id))
      logger.warn(err.message)
      raise Creator::Result::Error, Creator::DEFAULT_ERROR_MESSAGE
    rescue Creator::Result::Error => err
      creator.delete_github_repository(assignment_repo.try(:github_repo_id))
      raise err
    end
def create_assignment_repo ( assignment , user ) creator = Creator . new ( assignment : assignment , user : user ) creator . verify_organization_has_private_repos_available! github_repository = creator . create_github_repository! assignment_repo = assignment . assignment_repos . build ( github_repo_id : github_repository . id , github_global_relay_id : github_repository . node_id , user : user ) creator . add_user_to_repository! ( assignment_repo . github_repo_id ) creator . push_starter_code! ( assignment_repo . github_repo_id ) if assignment . starter_code? assignment_repo . save! assignment_repo rescue ActiveRecord :: RecordInvalid => err creator . delete_github_repository ( assignment_repo . try ( :github_repo_id ) ) logger . warn ( err . message ) raise Creator :: Result :: Error , Creator :: DEFAULT_ERROR_MESSAGE rescue Creator :: Result :: Error => err creator . delete_github_repository ( assignment_repo . try ( :github_repo_id ) ) raise err end
Creates an AssignmentRepo with an associated GitHub repo
If creation fails, it deletes the GitHub repo
Creates an AssignmentRepo with an associated GitHub repo If creation fails it deletes the GitHub repo
assignment
<not_specific>
user
<not_specific>