progmaticltd / homebox

A set of ansible scripts to build a personal mail server / private cloud / etc.
https://homebox.space/
GNU General Public License v3.0
465 stars 52 forks source link

git-hooks: pre-push improvements #302

Closed fredericmoulins closed 4 years ago

fredericmoulins commented 4 years ago

Apply the same logic as the pre-commit hook of exporting in a temporary directory the local branches, tags or commits being pushed. This allows to run the ansible-lint checks on any branch without touching the state of the working directory.

Loop over all the given references. Fail at the first error found.

Handle the case of remote branch deletion by not running ansible-lint.

Export all the files of the reference given by using git archive. Other alternatives could have been: git clone, but is quite verbose when not a proper branch, and the repository and origin configuration is not needed ; git worktree, but requires a special case for the currently checkout branch, and one wouldn't want to have dangling worktrees if something goes very wrong.

Use set -o pipefail, so require Bash.