Skip to content

In repository README example

Ondřej Caletka edited this page Sep 29, 2018 · 5 revisions

DNS zone git repository

This repository contains DNS zone files that are fed into master server automatically on every commit. Following rules apply:

  • everything ending with .zone is considered a zone file, everything else is ignored.

  • zone files have to be named by zone they represent. The only exception are zone names containing slashes, those should be substituted by dashes or underscores and proper $ORIGIN directive should be present in first lines of the zone file

  • every change to zone files that results in zone contents change (ie. not just white space or comment change) have increase the SOA serial number as well

  • zone file includes are not supported at this moment.

  • the checks are conducted both at the server side as well as locally. Read below on how to install local checks.

  • no other branch then master is accepted on the server side, neither are tags

Recommended workflow

  • do git pull to sync the repository with server. In case you encounter problems due to conflicts, either stash your work before (git stash) or reset to server state (git reset --hard origin/master - this will destroy any work in your directory)

  • make desired changes

  • run git add <file> and git commit. If you get into the editor, everything went well (or you haven't setup the pre-commit check properly)

  • push the changes to the server by git push

Recommended git setup

  • set git config pull.rebase true to prefer rebasing over 3-way merging during pulling from the remote repository

  • set git config commit.verbose true to see the diff what is going to be commited

  • install git-prompt.sh to watch current git status in your shell prompt - add this to your bashrc:

    export GIT_PS1_SHOWDIRTYSTATE=1
    export GIT_PS1_SHOWSTASHSTATE=1
    export GIT_PS1_SHOWUNTRACKEDFILES=1
    export PROMPT_COMMAND="$(echo $PS1 | sed -r 's&^(.*)([\][$].*)$&__git_ps1 "\1" "\\\2 " " \\[\\033[01;33m\\][%s]\\[\\033[00m\\]"&')"
    

Installing the pre-commit checks

  • install /usr/sbin/named-compilezone (package bind9utils in Debian)

  • ensure you have at least Python 3.5

  • download dzonegit.py, set it executable and rename/symlink it to your Git hooks repository:

     $ wget -O .git/hooks/pre-commit https://raw.githubusercontent.com/oskar456/dzonegit/master/dzonegit.py
     $ chmod +x .git/hooks/pre-commit
    
  • alternatively, install dzonegit Python package, preferrably into a virtual environment:

     $ python3 -m venv .venv
     $ source .venv/bin/activate
     (.venv)$ pip install dzonegit
     (.venv)$ deactivate
     $ ln -s ../../.venv/bin/dzonegit-pre-commit .git/hooks/pre-commit