Exercise format reference
Exercises follow a fixed structure for the Git-Mastery app to pick up on:
<exercise name>
├── .gitmastery-exercise.json
├── README.md
├── __init__.py
├── download.py
├── res
│ └── ...
├── test_verify.py
└── verify.py
.gitmastery-exercise.json: contains the exercise configurationREADME.md: contains the instructions for studentsdownload.py: contains the download instructions to set up the student’s exerciseverify.py: contains the verification script for the exercise attemptres/: contains resources that are available to studentstest_verify.py: contains unit tests for the verification script, written usingrepo-smith
What students see
When a student downloads a typical exercise, they will see the following folder structure:
<exercise name>
├── .gitmastery-exercise.json
├── README.md
└── <sub folder name>
├── .git
└── ...
The root of the exercise contains the configured README.md and .gitmastery-exercise.json.
It also contains the subfolder configured in .gitmastery-exercise.json, which is where students attempt the exercise.
Some exercises intentionally differ:
repo_type: ignore: no managed repository subfolder is created by the app; the student works directly in the exercise root.repo_type: local-ignore: the app creates the working folder but does not rungit initfor the student.
Configuration structure
.gitmastery-exercise.json is used to tell the Git-Mastery app how to set up the student’s exercise.
We opted to use a standardized configuration for exercises because they often follow a common setup shape.
The new.sh script generates one for you, but you can modify the file directly:
exercise_name: raw exercise name that will be indexed; recommended to use kebab casetags: specify topic related to exerciserequires_git: performs a check to ensure that Git is installed anduser.nameanduser.emailare configuredrequires_github: performs a check to ensure that GitHub CLI is installed and the user has authenticatedbase_files: specifies the files fromres/to be downloaded into the exercise rootexercise_repo: controls the subfolder that is generated; this is where students work on the exerciserepo_type: one oflocal,remote,ignore, orlocal-ignorerepo_name: name of the subfolderinit: determines ifgit initis run for the subfolder; used for local or local-ignore style repositoriescreate_fork: determines if a fork is created on the user’s GitHub account; used for remote repositoriesfork_all_branches: optional remote-only setting controlling whether all branches are forkedrepo_title: name of the remote repository to fork and clone; used for remote repositories
Repo type meanings
local: create a local subfolder and optionally initialize it as a Git repository.remote: clone a GitHub repository, optionally via a student fork.ignore: do not create or manage a working repository; verification should not depend onexercise.repo.local-ignore: create a local subfolder but do not initialize Git. This is useful for exercises where the student is expected to rungit initthemselves.
Exercise resource types
There are two distinct types of resources:
-
Base files: configured through the
base_filesproperty in.gitmastery-exercise.json; files located inres/are downloaded to the root of the exercise folder.<exercise name> ├── .gitmastery-exercise.json ├── README.md ├── <base files> └── <sub folder name> ├── .git └── ... -
Resources: configured through the
__resources__field indownload.py; supporting files fromres/are downloaded into the subfolder.<exercise name> ├── .gitmastery-exercise.json ├── README.md ├── <base files> └── <sub folder name> ├── .git └── <resources>