#6894 SVN/Git refresh hooks fail for redirects


Originally created by: rferreira-itav


I've been having a problem where repositories in an Allura instance failed to refresh after a git or svn commit was pushed into the repository. It turns out that the curl call in the repository hooks was hitting an HTTP redirect which caused it to never call the /auth/repo_refresh/ API.

Here is a detailed walkthrough.
Whenever a commit is pushed, a hook invokes curl to do a refresh, e.g.

curl http://staging.hostname.com//auth/refresh_repo/p/test/code/

Notice that this particular URL starts with a double slash (//). This happened because the base_url option in the settings file had a trailing slash i.e.

base_url = http://staging.hostname.com/

Since the hook generators in ForgeGit/forgegit/model/git_repo.py and ForgeSVN/forgesvn/model/svn.py generate the URL by appending the path to the base_url

url=tg.config.get('base_url', 'http://localhost:8080')
        + '/auth/refresh_repo' + self._repo.url())

the URL path will start with a double slash(//).

This will cause the webserver to return a 301 redirect with a fixed path

<title>301 Moved Permanently</title>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://staging.hostname.com/auth/refresh_repo/p/test/code/">here</a>.</p>

This will cause curl to immediately stop, because curl does not follow redirects by default.

A couple of solutions come to mind, but I don't know if the current behaviour is intentional or not, so they might not make sense:

  1. The quickest solution (for my case at least) was to fix the base_url, removing the trailing slash. But it might make sense in other setups for a redirect to be there. Also this does not fix existing repositories, since the hooks were already saved.
  2. Changing the hooks to pass the -L parameter to curl, causes curl to follow redirects
  3. Change ForgeGit/forgegit/model/git_repo.py and ForgeSVN/forgesvn/model/svn.py to sanitise the URL before generating the hook

Like I said, I don't know if the current behaviour (no redirects) is intentional or not, but at least (3.) would easily avoid trailing slash issues.

Hope this helps, cheers.


  • Dave Brondsema

    Dave Brondsema - 2013-12-13
    • status: open --> code-review
  • Dave Brondsema

    Dave Brondsema - 2013-12-13

    3 makes sense to me..

  • Cory Johns

    Cory Johns - 2014-01-09
    • QA: Cory Johns
    • Milestone: limbo --> forge-jan-10
  • Cory Johns

    Cory Johns - 2014-01-09
    • assigned_to: Cory Johns
    • Size: --> 1
  • Cory Johns

    Cory Johns - 2014-01-09
    • QA: Cory Johns --> nobody
  • Cory Johns

    Cory Johns - 2014-01-09


  • Tim Van Steenburgh

    • QA: Tim Van Steenburgh
  • Tim Van Steenburgh

    • status: code-review --> closed

Log in to post a comment.