e5347ffdcbc9e6e2fa5fb1226661998cffe9293d
[yaffs-website] / vendor / drush / drush / examples / git-bisect.example.sh
1 #!/usr/bin/env sh
2
3 #
4 # Git bisect is a helpful way to discover which commit an error
5 # occurred in.  This example file gives simple instructions for
6 # using git bisect with Drush to quickly find erroneous commits
7 # in Drush commands or Drupal modules, presuming that you can
8 # trigger the error condition via Drush (e.g. using `drush php-eval`).
9 #
10 # Follow these simple steps:
11 #
12 #   $ git bisect start
13 #   $ git bisect bad              # Tell git that the current commit does not work
14 #   $ git bisect good bcadd5a     # Tell drush that the commithash 12345 worked fine
15 #   $ git bisect run mytestscript.sh
16 #
17 # 'git bisect run' will continue to call 'git bisect good' and 'git bisect bad',
18 # based on whether the script's exit code was 0 or 1, respectively.
19 #
20 # Replace 'mytestscript.sh' in the example above with a custom script that you
21 # write yourself.  Use the example script at the end of this document as a
22 # guide.  Replace the example command with one that calls the Drush command
23 # that you would like to test, and replace the 'grep' string with a value
24 # that appears when the error exists in the commit, but does not appear when
25 # commit is okay.
26 #
27 # If you are using Drush to test Drupal or an external Drush module, use:
28 #
29 #   $ git bisect run drush mycommand --strict=2
30 #
31 # This presumes that there is one or more '[warning]' or '[error]'
32 # messages emitted when there is a problem, and no warnings or errors
33 # when the commit is okay.  Omit '--strict=2' to ignore warnings, and
34 # signal failure only when 'error' messages are emitted.
35 #
36 # If you need to test for an error condition explicitly, to find errors
37 # that do not return any warning or error log messages on their own, you
38 # can use the Drush php-eval command to force an error when `myfunction()`
39 # returns FALSE. Replace 'myfunction()' with the name of an appropriate
40 # function in your module that can be used to detect the error condition
41 # you are looking for.
42 #
43 #   $ git bisect run drush ev 'if(!myfunction()) { return drush_set_error("ERR"); }'
44 #
45 drush mycommand --myoption 2>&1 | grep -q 'string that indicates there was a problem'
46 if [ $? == 0 ] ; then
47   exit 1
48 else
49   exit 0
50 fi