You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@allura.apache.org by Cory Johns <ma...@users.sf.net> on 2014/01/09 23:35:00 UTC

[allura:tickets] #6894 SVN/Git refresh hooks fail for redirects

- **QA**: Cory Johns
- **Milestone**: limbo --> forge-jan-10



---

** [tickets:#6894] SVN/Git refresh hooks fail for redirects**

**Status:** code-review
**Labels:** git svn curl 
**Created:** Tue Nov 19, 2013 02:13 PM UTC by Rui Ferreira
**Last Updated:** Fri Dec 13, 2013 05:33 PM UTC
**Owner:** nobody

Hi

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

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>301 Moved Permanently</title>
    </head><body>
    <h1>Moved Permanently</h1>
    <p>The document has moved <a href="http://staging.hostname.com/auth/refresh_repo/p/test/code/">here</a>.</p>
    </body></html>

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.




---

Sent from sourceforge.net because allura-dev@incubator.apache.org is subscribed to https://sourceforge.net/p/allura/tickets/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/allura/admin/tickets/options.  Or, if this is a mailing list, you can unsubscribe from the mailing list.