webkit-tools-completion.sh 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # Copyright (C) 2009 Google Inc. All rights reserved.
  2. #
  3. # Redistribution and use in source and binary forms, with or without
  4. # modification, are permitted provided that the following conditions are
  5. # met:
  6. #
  7. # * Redistributions of source code must retain the above copyright
  8. # notice, this list of conditions and the following disclaimer.
  9. # * Redistributions in binary form must reproduce the above
  10. # copyright notice, this list of conditions and the following disclaimer
  11. # in the documentation and/or other materials provided with the
  12. # distribution.
  13. # * Neither the name of Google Inc. nor the names of its
  14. # contributors may be used to endorse or promote products derived from
  15. # this software without specific prior written permission.
  16. #
  17. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  20. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  21. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  22. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  24. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  25. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. #
  29. # Command line completion for common commands used in WebKit development.
  30. #
  31. # Set-up:
  32. # Add a line like this to your .bashrc:
  33. # source /path/to/WebKitCode/Tools/Scripts/webkit-tools-completion.sh
  34. __webkit-patch_generate_reply()
  35. {
  36. COMPREPLY=( $(compgen -W "$1" -- "${COMP_WORDS[COMP_CWORD]}") )
  37. }
  38. __webkit-patch_upload_cc_generate_reply()
  39. {
  40. # Note: This won't work well if hostname completion is enabled, disable it with: shopt -u hostcomplete
  41. # Completion is done on tokens and our comma-separated list is one single token, so we have to do completion on the whole list each time.
  42. # Return a \n separated list for each possible bugzilla email completion of the substring following the last comma.
  43. # Redirect strerr to /dev/null to prevent noise in the shell if this ever breaks somehow.
  44. COMPREPLY=( $(PYTHONPATH=$(dirname "${BASH_SOURCE[0]}") python -c "
  45. import sys,re
  46. from webkitpy.common.config.committers import CommitterList
  47. m = re.match('((.*,)*)(.*)', sys.argv[1])
  48. untilLastComma = m.group(1)
  49. afterLastComma = m.group(3)
  50. print('\n'.join([untilLastComma + c.bugzilla_email() + ',' for c in CommitterList().contributors() if c.bugzilla_email().startswith(afterLastComma)]))" "${COMP_WORDS[COMP_CWORD]}" 2>/dev/null ) )
  51. }
  52. _webkit-patch_complete()
  53. {
  54. local command current_command="${COMP_WORDS[1]}"
  55. case "$current_command" in
  56. -h|--help)
  57. command="help";
  58. ;;
  59. *)
  60. command="$current_command"
  61. ;;
  62. esac
  63. if [ $COMP_CWORD -eq 1 ]; then
  64. __webkit-patch_generate_reply "--help apply-from-bug bugs-to-commit commit-message land land-from-bug obsolete-attachments patches-to-commit post upload tree-status rollout reviewed-patches"
  65. return
  66. fi
  67. case "$command" in
  68. apply-from-bug)
  69. __webkit-patch_generate_reply "--force-clean --local-commit --no-clean --no-update"
  70. return
  71. ;;
  72. commit-message)
  73. return
  74. ;;
  75. land)
  76. __webkit-patch_generate_reply "--no-build --no-close --no-test --reviewer= -r"
  77. return
  78. ;;
  79. land-from-bug)
  80. __webkit-patch_generate_reply "--force-clean --no-build --no-clean --no-test"
  81. return
  82. ;;
  83. obsolete-attachments)
  84. return
  85. ;;
  86. post)
  87. __webkit-patch_generate_reply "--description --no-obsolete --no-review --request-commit -m --open-bug"
  88. return
  89. ;;
  90. upload)
  91. if [[ ${COMP_WORDS[COMP_CWORD-1]} == "--cc" || ${COMP_WORDS[COMP_CWORD-1]} == "=" && ${COMP_WORDS[COMP_CWORD-2]} == "--cc" ]]; then
  92. __webkit-patch_upload_cc_generate_reply
  93. return
  94. fi
  95. __webkit-patch_generate_reply "--description --no-obsolete --no-review --request-commit --cc -m --open-bug"
  96. return
  97. ;;
  98. post-commits)
  99. __webkit-patch_generate_reply "--bug-id= --no-comment --no-obsolete --no-review -b"
  100. return
  101. ;;
  102. esac
  103. }
  104. complete -F _webkit-patch_complete webkit-patch
  105. complete -o default -W "--continue --fix-merged --help --no-continue --no-warnings --warnings -c -f -h -w" resolve-ChangeLogs
  106. complete -o default -W "--bug --diff --git-commit --git-index --git-reviewer --help --no-update --no-write --open --update --write -d -h -o" prepare-ChangeLog
  107. complete -W "--clean --debug --help -h" build-webkit
  108. complete -o default -W "--add-platform-exceptions --complex-text --configuration --guard-malloc --help --http --ignore-tests --launch-safari --leaks --merge-leak-depth --new-test-results --no-http --no-show-results --no-new-test-results --no-sample-on-timeout --no-strip-editing-callbacks --pixel-tests --platform --port --quiet --random --reset-results --results-directory --reverse --root --sample-on-timeout --singly --skipped --slowest --strict --strip-editing-callbacks --threaded --timeout --tolerance --use-remote-links-to-tests --valgrind --verbose -1 -c -g -h -i -l -m -o -p -q -t -v" run-webkit-tests