<commit_before># Subtrigger

A simple DSL for defining callbacks to be fired as Subversion hooks with
built-in support for inspecting the repository and sending out e-mails.

## Example Usage

This library is intended for use as a Subversion post-commit hook. It allows
you to define callbacks that fire when certain conditions on a revision are
met. Simply require Subtrigger and define your rules:

    require 'subtrigger'

    on /deploy to (\w+)/ do |revision, matches|
      puts "Should deploy to #{matches[:message].first}"
    end

Save this as a file in your Subversion repository, like
`/path/to/repo/hooks/deploy.rb`. Then in your Subversion commit hook
file (`/path/to/repo/hooks/post-commit`) simply call the file using
Ruby:

    /usr/bin/ruby -rubygems /path/to/repo/hooks/deploy.rb "$1" "$2"

You could define triggers to…

* Send out confirmation e-mails to specific developers
* Auto-update a working copy on a production server
* Create a back-up archive
* Whatever else you can do with Ruby…

## Detailed usage

### Matchers

The default usage in the example above uses a regular expression which by
default will be matched against the log message of the revision that
triggers the hook. But you can test both other attributes and with other
objects (basically anything that responds to `#===`).

    # Test on author name
    # You can use `:author`, `:message`, `:date`,
    # `:number`
    on :author => /john|graham|michael|terry/ do
      puts 'Always look on the bright side of life!'
    end

    # Test using a matcher object
    class EvenNumberMatcher
      def ===(revision)
        revision.number % 2 == 0
      end
    end
    on :number => EvenNumberMatcher.new do
      puts 'The revision number is an even number'
    end

### Sending e-mails

Subtrigger uses Pony to enable the sending of e-mails straigt from your
triggers. This means you can send an e-mail when a branch is created, just
to name an example.

    on /confirm via email/ do
      mail :to      => '<EMAIL>',
           :from    => '<EMAIL>',
           :subject => 'E-mail confirmation of commit',
           :body    => 'Your commit has been saved.'
    end

### Inline templates

To remove long strings from your templates you can define templates right
in your rules file.

    on /confirm via email/ do |r|
      mail :to      => '<EMAIL>',
           :from    => '<EMAIL>',
           :subject => 'E-mail confirmation of commit',
           :body    => template('E-mail confirmation', r.number)
    end
    __END__
    @@ E-mail confirmation
    Your commit (%s) has been saved
    @@ Other template
    ...

This will result in an e-mail like `Your commit (5299) has been
saved`.

### Running the triggers

Note that all triggers are run when your rules file ends (using the global
`at_exit` callback). There's no need to explicitly start this process
yourself.

## Warnings

Note that subversion calls its hooks in an empty environment, so there's
no `$PATH` or anything. Always use full absolute paths. Also, hooks are
notoriously hard to debug, so make sure to write some debugging information
somewhere so you know what is going on.

## Credits

* **Author**: <NAME>
* **E-mail**: <EMAIL>
* **URL**: http://arjanvandergaag.nl
* **Source**: http://github.com/avdgaag/subtrigger

## Note on Patches/Pull Requests

* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
  future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
  (if you want to have your own version, that is fine but bump version in a
  commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.

## License

Copyright (c) 2010 <NAME>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<commit_msg>Added changes to readme<commit_after># Subtrigger

A simple DSL for defining callbacks to be fired as Subversion hooks with
built-in support for inspecting the repository and sending out e-mails.

## Example Usage

This library is intended for use as a Subversion post-commit hook. It allows
you to define callbacks that fire when certain conditions on a revision are
met. Simply require Subtrigger and define your rules:

    require 'subtrigger'

    on /deploy to (\w+)/ do |revision, matches|
      puts "Should deploy to #{matches[:message].first}"
    end

Save this as a file in your Subversion repository, like
`/path/to/repo/hooks/deploy.rb`. Then in your Subversion commit hook
file (`/path/to/repo/hooks/post-commit`) simply call the file using
Ruby:

    /usr/bin/ruby -rubygems /path/to/repo/hooks/deploy.rb "$1" "$2"

You could define triggers to…

* Send out confirmation e-mails to specific developers
* Auto-update a working copy on a production server
* Create a back-up archive
* Whatever else you can do with Ruby…

## Detailed usage

### Matchers

The default usage in the example above uses a regular expression which by
default will be matched against the log message of the revision that
triggers the hook. But you can test both other attributes and with other
objects (basically anything that responds to `#===`).

    # Test on author name
    # You can use `:author`, `:message`, `:date`,
    # `:number`
    on :author => /john|graham|michael|terry/ do
      puts 'Always look on the bright side of life!'
    end

    # Test using a matcher object
    class EvenNumberMatcher
      def ===(revision)
        revision.number % 2 == 0
      end
    end
    on :number => EvenNumberMatcher.new do
      puts 'The revision number is an even number'
    end

### Sending e-mails

Subtrigger uses Pony to enable the sending of e-mails straigt from your
triggers. This means you can send an e-mail when a branch is created, just
to name an example.

    on /confirm via email/ do
      mail :to      => '<EMAIL>',
           :from    => '<EMAIL>',
           :subject => 'E-mail confirmation of commit',
           :body    => 'Your commit has been saved.'
    end

### Inline templates

To remove long strings from your templates you can define templates right
in your rules file.

    on /confirm via email/ do |r|
      mail :to      => '<EMAIL>',
           :from    => '<EMAIL>',
           :subject => 'E-mail confirmation of commit',
           :body    => template('E-mail confirmation', r.number)
    end
    __END__
    @@ E-mail confirmation
    Your commit (%s) has been saved
    @@ Other template
    ...

This will result in an e-mail like `Your commit (5299) has been
saved`.

### Running the triggers

Note that all triggers are run when your rules file ends (using the global
`at_exit` callback). There's no need to explicitly start this process
yourself.

## Warnings

Note that subversion calls its hooks in an empty environment, so there's
no `$PATH` or anything. Always use full absolute paths. Also, hooks are
notoriously hard to debug, so make sure to write some debugging information
somewhere so you know what is going on.

## Changes

Note that Subtrigger is still in early stages of development.
Until it hits 1.0 there are bound to be major changes. 

### 0.3.0

* Complete rewrite of the system
* Improved documentation
* Improved test coverage
* Added matching on more revision attributes
* Added custom matcher objects
* Use Pony for e-mail
* Cleaner rules files

## Credits

* **Author**: <NAME>
* **E-mail**: <EMAIL>
* **URL**: http://arjanvandergaag.nl
* **Source**: http://github.com/avdgaag/subtrigger

## Note on Patches/Pull Requests

* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
  future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
  (if you want to have your own version, that is fine but bump version in a
  commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.

## License

Copyright (c) 2010 <NAME>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

{'fraction_non_alphanumeric': 0.07434944237918216, 'fraction_numerical': 0.00291369436350849, 'mean_word_length': 3.4616763783056923, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 37, 'https://': 0, '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': '3557925', 'n_tokens_mistral': 2745, 'n_tokens_neox': 2640, 'n_words': 1406}