from Hacker News

Show HN: Git-Ready to Deploy? Check for uncommitted and non-pushed changes

by oleks on 6/2/18, 10:29 AM with 23 comments

  • by tomxor on 6/2/18, 1:26 PM

    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:

        - 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.
    
    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:

    https://github.com/LearningScience/pegit

  • by wereHamster on 6/2/18, 10:56 AM

    Do you know about `git-sh-setup`? As in:

        . "$(git --exec-path)/git-sh-setup"
        require_clean_work_tree "bump" "Please commit or stash them."
        
    
    https://git-scm.com/docs/git-sh-setup
  • by TekMol on 6/2/18, 10:42 AM

    I'm confused. How is that different from 'git status'?
  • by colemickens on 6/2/18, 1:11 PM

    `git status --porcelain` and `if git diff-index --quiet HEAD -- ; then ...` might be lighter/easier ways (and include non-staged files [as well]).

    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 will deploy to Prod and forget to push their config changes, eventually.

  • by kbob on 6/3/18, 9:05 PM

    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.

    https://kbob.github.io/2016/11/08/check-git

  • by kinow on 6/2/18, 12:09 PM

    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 https://github.com/apache/maven-scm?files=1)
  • by wiz21c on 6/2/18, 11:45 AM

    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...
  • by _ZeD_ on 6/2/18, 12:56 PM

    ok, seriously, is "using git push to do a deploy" a thing? WTF?