abc-classroom.github

abcclassroom.github.add_remote(directory, organization, remote_repo)[source]
abcclassroom.github.check_student_repo_exists(org, course, student, token=None)[source]

Check if the student has a repository for the course.

It happens that students delete their repository or do not accept the invitation to the course. In either case they will not have a repository yet.

abcclassroom.github.clone_repo(organization, repo, dest_dir)[source]

Clone repository from org into a sub-directory in directory. Assumes you have ssh keys setup for github (rather than using GitHub API token).

abcclassroom.github.close_existing_pullrequests(org, repository, branch_base='new-material-', token=None)[source]

Close all oustanding course material update Pull Requests

If there are any PRs open in a student’s repository that originate from a branch starting with branch_base as name and created by the user we are logged in we close them.

abcclassroom.github.commit_all_changes(directory, msg=None)[source]

Run git add, git commit on a given directory. Checks git status first and does nothing if no changes.

abcclassroom.github.create_pr(org, repository, branch, message, token)[source]

Create a Pull Request with changes from branch

abcclassroom.github.create_repo(org, repository, token)[source]

Create a repository in the provided GitHub organization.

abcclassroom.github.fetch_student(org, course, student, directory, token=None)[source]

Fetch course repository for student from org

The repository will be cloned into a sub-directory in directory.

Returns the directory in which to find the students work.

abcclassroom.github.get_access_token()[source]

Get a GitHub access token for the API

First tries to read from local token file. If token does not exist, or is not valid, generates a new token using the OAuth Device Flow. https://docs.github.com/en/free-pro-team@latest/developers/apps/ identifying-and-authorizing-users-for-github-apps#device-flow

Returns an access token (string).

abcclassroom.github.get_commit_message()[source]
abcclassroom.github.git_init(directory, defaultbranch='main')[source]

Initialize git repository

abcclassroom.github.init_and_commit(directory, custom_message=False)[source]

Run git init, git add, git commit on given directory. Checks git status first and does nothing if no changes.

abcclassroom.github.new_branch(directory, name=None)[source]

Create a new git branch in directory

abcclassroom.github.pull_from_github(directory, branch='master')[source]

Pull branch of local repo in directory from GitHub

abcclassroom.github.push_to_github(directory, branch='main')[source]

Push branch back to GitHub

abcclassroom.github.remote_repo_exists(org, repository, token=None)[source]

Check if the remote repository exists for the organization.

abcclassroom.github.repo_changed(directory)[source]

Determine if the Git repository in directory is dirty