├── .gitignore ├── LICENSE ├── Makefile ├── README.md └── git-ready-to-deploy.m4 /.gitignore: -------------------------------------------------------------------------------- 1 | git-ready-to-deploy.sh 2 | 3 | # Created by https://www.gitignore.io/api/vim,emacs 4 | 5 | ### Emacs ### 6 | # -*- mode: gitignore; -*- 7 | *~ 8 | \#*\# 9 | /.emacs.desktop 10 | /.emacs.desktop.lock 11 | *.elc 12 | auto-save-list 13 | tramp 14 | .\#* 15 | 16 | # Org-mode 17 | .org-id-locations 18 | *_archive 19 | 20 | # flymake-mode 21 | *_flymake.* 22 | 23 | # eshell files 24 | /eshell/history 25 | /eshell/lastdir 26 | 27 | # elpa packages 28 | /elpa/ 29 | 30 | # reftex files 31 | *.rel 32 | 33 | # AUCTeX auto folder 34 | /auto/ 35 | 36 | # cask packages 37 | .cask/ 38 | dist/ 39 | 40 | # Flycheck 41 | flycheck_*.el 42 | 43 | # server auth directory 44 | /server/ 45 | 46 | # projectiles files 47 | .projectile 48 | projectile-bookmarks.eld 49 | 50 | # directory configuration 51 | .dir-locals.el 52 | 53 | # saveplace 54 | places 55 | 56 | # url cache 57 | url/cache/ 58 | 59 | # cedet 60 | ede-projects.el 61 | 62 | # smex 63 | smex-items 64 | 65 | # company-statistics 66 | company-statistics-cache.el 67 | 68 | # anaconda-mode 69 | anaconda-mode/ 70 | 71 | ### Vim ### 72 | # swap 73 | .sw[a-p] 74 | .*.sw[a-p] 75 | # session 76 | Session.vim 77 | # temporary 78 | .netrwhist 79 | # auto-generated tag files 80 | tags 81 | 82 | 83 | # End of https://www.gitignore.io/api/vim,emacs 84 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-2018 Oleks 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean 2 | 3 | HEAD_PATH=.git/$(shell cat .git/HEAD | cut -d' ' -f2) 4 | 5 | git-ready-to-deploy.sh: \ 6 | git-ready-to-deploy.m4 \ 7 | LICENSE \ 8 | Makefile \ 9 | $(HEAD_PATH) 10 | m4 -D "HEAD_PATH=$(HEAD_PATH)" $< > $@ 11 | chmod +x $@ 12 | ./$@ 13 | 14 | clean: 15 | rm -f git-ready-to-deploy.sh 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Get Ready to Deploy! 2 | 3 | `git-ready-to-deploy.sh` (pronounced "get ready to deploy") can ensure 4 | that the local clone is clean (no uncommitted changes), and that there 5 | are no local commits to be pushed upstream. 6 | 7 | This is useful in a manual deployment setting, where you want to 8 | ensure that: 9 | 10 | 1. Nothing uncommitted gets deployed. 11 | 2. Nothing not yet applied upstream gets deployed. 12 | 13 | For example, this repository uses `git-ready-to-deploy.sh` on itself, 14 | to help assure the quality of its 15 | [releases](https://github.com/oleks/git-ready-to-deploy/releases). 16 | 17 | [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/oleks/git-ready-to-deploy/blob/master/LICENSE) 18 | 19 | ## Where's the Shell Script? 20 | 21 | To ensure proper accreditation, manage releases, and reduce code 22 | duplication, `git-ready-to-deploy.sh` is generated from [an m4 23 | template](git-ready-to-deploy.m4). To get the shell script, either: 24 | 25 | 1. Fetch the 26 | [latest](https://github.com/oleks/git-ready-to-deploy/releases/latest) 27 | [release](https://github.com/oleks/git-ready-to-deploy/releases) of 28 | the shell script, or; 29 | 2. Type `make` to build it, if you happen to have the [m4 macro 30 | processor](https://www.gnu.org/software/m4/m4.html) installed. 31 | 32 | Please note, the last step of building `git-ready-to-deploy.sh` is to 33 | execute the thus built `git-ready-to-deploy.sh`. This ensures a clean 34 | release of `git-ready-to-deploy.sh`, so long as you mind the exit code 35 | from `make`. 36 | 37 | ## Target Audience 38 | 39 | This script should be used only if applicable in your deployment 40 | process. In particular, a deployment process where someone, perhaps a 41 | bot, can pull, make changes, and *can* deploy without committing and 42 | pushing back first. 43 | 44 | In this scenario, this script is best-used as an integral part of your 45 | "deploy script". `git-ready-to-deploy.sh` fails, if there are changes 46 | to be committed, or pushed. If used properly, it can prohibit 47 | deployment of ill-versioned code. 48 | 49 | Alternative deployment strategies include push-to-deploy, or 50 | push-to-staging, with a subsequent process for deploying from staging. 51 | This script is unlikely to be useful in these scenarios. 52 | 53 | ## Community Review 54 | 55 | Discussed on [Hacker 56 | News](https://news.ycombinator.com/item?id=17213891). 57 | -------------------------------------------------------------------------------- /git-ready-to-deploy.m4: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This file was generated from an m4 template. 4 | syscmd(`date -u --iso-8601=minutes | 5 | sed "s/^/# Generation date-time (ISO 8601): /"')dnl 6 | syscmd(`git remote get-url origin | 7 | tr ":" "/" | 8 | sed "s/^git@/https:\\/\\//" | 9 | sed "s/\\.git$//" | 10 | sed "s/^/# Git repository URL: /"')dnl 11 | format(`# Commit ID: %s', include(HEAD_PATH))dnl 12 | 13 | syscmd(`perl -pe "chomp if eof" LICENSE | 14 | sed "s/^/# /"') 15 | 16 | set -euo pipefail 17 | 18 | failcode=1 19 | 20 | nlines=$(git status . --porcelain | wc -l) 21 | if [ ${nlines} -ne 0 ] ; then 22 | cat <