I wrote a git-tag based cli content deployment tool that does something like this as part of the deploy stage. It's intended for use with multiple users with a single remote, so before attempting to deploy anything it does the following to ensure no conflicts and that outdated content is never accidentally deployed:<p><pre><code> - Fetches
- Checks the branch you are deploying from hasn't diverged from it's tracking branch.
- Checks whether each path+tree-object combo trying to be deployed has already been tagged.
- Checks whether each tree path being deployed is clean.
- Finally, if it fails to push new tags it reverts everything to prevent deploys unavailable to everyone else.
</code></pre>
I built this for a special type of content deployment for the company I work for but I think it's only been used internally so far (albeit successfully) - I made the tool as generalised as possible though as the core concept is quite re-usable, but I don't think I have described it's purpose clearly enough for the rest of the world in the readme:<p><a href="https://github.com/LearningScience/pegit" rel="nofollow">https://github.com/LearningScience/pegit</a>
Do you know about `git-sh-setup`? As in:<p><pre><code> . "$(git --exec-path)/git-sh-setup"
require_clean_work_tree "bump" "Please commit or stash them."
</code></pre>
<a href="https://git-scm.com/docs/git-sh-setup" rel="nofollow">https://git-scm.com/docs/git-sh-setup</a>
`git status --porcelain` and `if git diff-index --quiet HEAD -- ; then ...` might be lighter/easier ways (and include non-staged files [as well]).<p>Er, I guess that doesn't tell if you if you have un-pushed changes... but if your deployment process allows someone to deploy without pushing, your process is broken. Someone <i>will</i> deploy to Prod and forget to push their config changes, eventually.
On a somewhat related note, I created check-git a few months ago. It scans a directory tree for unclean git repositories. Maybe someone will find it useful.<p><a href="https://kbob.github.io/2016/11/08/check-git" rel="nofollow">https://kbob.github.io/2016/11/08/check-git</a>
Useful. Maven checks that for autpmated deployments. It delegates that part to SCM plugins as far as I know. Wonder if this one does the same as Maven. On mobile, but may check later (tis probably around here <a href="https://github.com/apache/maven-scm?files=1" rel="nofollow">https://github.com/apache/maven-scm?files=1</a>)
In my job I've written a small script that compares JIRA entries to what lies into git. This I way I can spot things that were forgotten or put on the wrong branch...