Skip to content

Post Editor: GitHub API Code

andy-wojciechowski edited this page Oct 5, 2019 · 1 revision

Terminology

Refs: Anything that points to a commit. For example, this can be a branch, tag, etc. Trees: represents the file structure in a git repository and creates the relationship between directories and the files they contain. Blobs: used to store the contents of each file in a repository.

Post Submission Code

  1. Creates a ref representing a new branch to push a new post/post changes to. That new ref will then point to the head of master. This represents "branching from master".
  2. Then a new tree is created containing the path of all files related to the post along with the file contents. The files included in the tree is the markdown file representing the actual post and any attached images. The tree is created from the base tree being the tree at the head of master. The contents of the files are represented as blobs encoded with base 64.
  3. Then a new commit is created using the new tree, and then the new ref is updated to point to the new commit. This represents committing and pushing to a git repository.
  4. Then a new pull request is opened from the new branch into master and the webmaster is requested for review on the pull request.