[WIP] Delete/Disable Webhooks and Add webhook testing

Review Request #9585 — Created Feb. 4, 2018 and updated

Florie Cai
rb-gateway, students

Updating README section of how to run rb-gateway server

Added 2 functions:
1) (webhook Webhook)Delete
2) (webhook

Adding testing for webhook.go. Need to figure out how to read the http responses from my dummy URL.

I read an article disgusting doing the teardown and setup in main_test.go and having individual functions there instead of in their own test file. I need to look at it some more to decide where to put this "setup/teardown" logic.


  • 0
  • 0
  • 3
  • 0
  • 3
Description From Last Updated
Florie Cai
Florie Cai
Florie Cai
Barret Rennie
  2. git_repository.go (Diff revision 4)

    Remove this.

  3. git_repository.go (Diff revision 4)

    So the method you're doing here will work, but it does modify existing files (which we probably do not want to do).

    Instead how about the following approach:

    1. Make a new directory .git/hooks/{SCRIPT_TYPE}.d, where SCRIPT_TYPE is e.g., post-commit
    2. If .git/hooks/{SCRIPT_TYPE} exists, move it to .git/hooks/{SCRIPT_TYPE}.d/00-original
    3. Install our hook script as .git/hooks/{SCRIPT_TYPE}.d/99-rbgateway:
    4. Create a new .git/hooks/{SCRIPT_TYPE} with the following template (see here):

    for HOOK in { .ScriptType }.d/*; do
        if [ -x "${HOOK}" ]; then
            /bin/sh -c $HOOK

    This allows us to install our own hooks without modifying the hooks already installed, as well as allows the maintainers to add multiple hooks.

    Also, since git by default has a hooks directory full of examples that are not marked +x, we can safely copy them into the hooks/{SCRIPT_TYPE}.d/ directory. In your original implementation, if the original git hook is made by git and non-executable, the code won't run.

    Additionally we can chmod +x .git/hooks/{SCRIPT_TYPE}/99-rbgateway with os.Chmod.

    1. What's the significance of 00 and 99? and the .d extension?

    2. Its a convention. .d means directory, e.g. conf.d is the "configuration directory".

      the 00, 99 determine what will execute first. 00 will appear in a directory listing before 99 so 00-foo.sh will execute before 99-foo.sh using that script above.

  4. git_repository.go (Diff revision 4)

    Git hooks should be named post-commit, etc. without the .sh.

Florie Cai
Florie Cai
Florie Cai
Review request changed




Revision 7 (+895 -76)

Show changes

Checks run (2 succeeded)

flake8 passed.
JSHint passed.