abc-classroom.git¶
- abcclassroom.git.check_git_ssh()[source]¶
Tests that ssh access to GitHub is set up correctly on the users computer.
Throws a RuntimeError if setup is not working.
- abcclassroom.git.clone_repo(organization, repo, dest_dir)[source]¶
Clone repository from org into a sub-directory in directory.
Raises RuntimeError if ssh keys not set up correctly, or if git clone fails for other reasons.
- Parameters
organization (string) – A string with the name of the organization to clone from
repo (string) – A string with the name of the GitHub repository to clone
dest_dir (string) – Path to the destination directory TODO: is this a full path, path object or string - what format is dest_dir in
- Return type
Cloned github repository in the destination directory specified.
- abcclassroom.git.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.git.init_and_commit(directory, commit_message)[source]¶
Run git init, git add, git commit on given directory. Checks git status first and does nothing if no changes are detected.
- Parameters
directory (Pathlib Path object?) – A relative or full Path to the directory that needs to be initialized via git init.
custom_message (str (defaults to default message - 'Initial commit')) – String with a custom message if you wish the first commit to not be the stock git init message provided by abc-classroom.
- Returns
Initializes the specified directory with a .git file and associated
tracking
- abcclassroom.git.pull_from_github(directory, branch='main')[source]¶
Pull branch of local repo in directory from GitHub.
Assumes git remotes are already setup.
- Parameters
directory (PathLib Path object) – A path to the local directory where the git repo of interest is saved.
branch (str) – A string representing the branch that you wish to pull. Default = main
- Return type
Pulls any new commits to the repo from GitHub to local computer.
- abcclassroom.git.push_to_github(directory, branch='main')[source]¶
Push branch of the repository in directory back to GitHub
Assumes git remotes are already setup.
- Parameters
directory (PathLib Path object) – A path to the local directory where the git repo of interest is saved.
branch (str) – A string representing the branch that you wish to pull. Default = main
- Return type
Pushes any new commits to the repo locally to GitHub.