<commit_before># cap_git_tools

Re-usable, composable [Capistrano](https://github.com/capistrano/capistrano) tasks for git tagging and other work with the
git repository you use for your Cap deploys. 

* Ensure your local git is committed and pushed, so you are deploying what you
think you are. 
* Automatically git tag the deploy
* Enforce a [multistage](https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension) workflow where only a tagged staging release can be deployed
to production (ala [gitflow](https://github.com/apinstein/git-deployment))

Functionality is split into discrete yet composable tasks, with sensible defaults 
but configurable, so you can build a cap recipe that fits *your*
requirements and workflow. Ordinary single stage or multi-stage; with or without
interactive confirmation prompts; using git however you're already or would like
to be using it. 

(_Inspired by <NAME> and <NAME>' neat
[gitflow](https://github.com/apinstein/git-deployment), but refactored for more
flexiblity with less hardcoded workflow. Some functionality changed in the
process.)

## Installation

    gem install cap_git_tools
    
Or if in the context of something using bundler such as Rails, add to Gemfile
eg:

    gem 'cap_git_tools', :group => :development
    
Add to top of a relevant Capistrano file (such as config/deploy.rb ordinarily):

    require 'cap_git_tools/tasks'
    
This makes cap_git_tool's tasks available to you, but doesn't automatically wire
them up to be used by your `cap deploy`. See below.

You probably want to make sure you have an `ssh-agent` set up, or you'll have to
enter your private key password to access git several times. **Note**: You will need to be
running your cap recipes from a directory with a git checkout (usual behavior
for cap usage, but not actually required otherwise by cap). 

## Ensure git is committed and pushed when deploying

Have you ever deployed the 'wrong' thing, because you forgot to commit and/or
push your changes to git?  I have. 

Have cap make sure you're committed and pushed before deploying by adding to
your recipe in deploy.rb: 

    before "deploy:update_code", "git:guard_committed", "git:guard_upstream"
    
Or use just one or the other

* `guard_committed` makes sure you have no uncommitted changes. _IF_ you have a :branch set
   in your cap recipe, it will also make sure your curent checkout matches that branch. 
* `guard_upstream` makes sure the current working copy branch committed tip (or local branch matching Cap
  :branch, if set) matches the upstream remote version. 
 
## Automatically tag on deploy<commit_msg>add newline to README for more clarity<commit_after># cap_git_tools

Re-usable, composable [Capistrano](https://github.com/capistrano/capistrano) tasks for git tagging and other work with the
git repository you use for your Cap deploys. 

* Ensure your local git is committed and pushed, so you are deploying what you
think you are. 
* Automatically git tag the deploy
* Enforce a [multistage](https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension) workflow where only a tagged staging release can be deployed
to production (ala [gitflow](https://github.com/apinstein/git-deployment))

Functionality is split into discrete yet composable tasks, with sensible defaults 
but configurable, so you can build a cap recipe that fits *your*
requirements and workflow. Ordinary single stage or multi-stage; with or without
interactive confirmation prompts; using git however you're already or would like
to be using it. 

(_Inspired by <NAME> and <NAME>' neat
[gitflow](https://github.com/apinstein/git-deployment), but refactored for more
flexiblity with less hardcoded workflow. Some functionality changed in the
process.)

## Installation

    gem install cap_git_tools
    
Or if in the context of something using bundler such as Rails, add to Gemfile
eg:

    gem 'cap_git_tools', :group => :development
    
Add to top of a relevant Capistrano file (such as config/deploy.rb ordinarily):

    require 'cap_git_tools/tasks'
    
This makes cap_git_tool's tasks available to you, but doesn't automatically wire
them up to be used by your `cap deploy`. See below.

You probably want to make sure you have an `ssh-agent` set up, or you'll have to
enter your private key password to access git several times. 

**Note**: You will need to be
running your cap recipes from a directory with a git checkout (usual behavior
for cap usage, but not actually required otherwise by cap). 

## Ensure git is committed and pushed when deploying

Have you ever deployed the 'wrong' thing, because you forgot to commit and/or
push your changes to git?  I have. 

Have cap make sure you're committed and pushed before deploying by adding to
your recipe in deploy.rb: 

    before "deploy:update_code", "git:guard_committed", "git:guard_upstream"
    
Or use just one or the other

* `guard_committed` makes sure you have no uncommitted changes. _IF_ you have a :branch set
   in your cap recipe, it will also make sure your curent checkout matches that branch. 
* `guard_upstream` makes sure the current working copy branch committed tip (or local branch matching Cap
  :branch, if set) matches the upstream remote version. 
 
## Automatically tag on deploy
{'fraction_non_alphanumeric': 0.06099640083349119, 'fraction_numerical': 0.00037885963250615644, 'mean_word_length': 4.415384615384616, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '36759', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1386, 'n_words': 723}