
class WebhookRequestParser(object):
    """Abstract parent class for git service parsers. Contains helper
    methods."""

    def __init__(self, config):
        self._config = config

    def get_matching_repo_configs(self, urls):
        """Iterates over the various repo URLs provided as argument (git://,
        ssh:// and https:// for the repo) and compare them to any repo URL
        specified in the config"""

        configs = []
        for url in urls:
            for repo_config in self._config['repositories']:
                if repo_config in configs:
                    continue
                if repo_config['url'] == url:
                    configs.append(repo_config)
                elif 'url_without_usernme' in repo_config and repo_config['url_without_usernme'] == url:
                    configs.append(repo_config)

        return configs

class WebhookRequestParser(object):
    """Abstract parent class for git service parsers. Contains helper
    methods."""

    def __init__(self, config):
        self._config = config

    def get_matching_repo_configs(self, urls):
        """Iterates over the various repo URLs provided as argument (git://,
        ssh:// and https:// for the repo) and compare them to any repo URL
        specified in the config"""

        configs = []
        for url in urls:
            for repo_config in self._config['repositories']:
                if repo_config in configs:
                    continue
                if repo_config.get('repo', repo_config.get('url')) == url:
                    configs.append(repo_config)
                elif 'url_without_usernme' in repo_config and repo_config['url_without_usernme'] == url:
                    configs.append(repo_config)

        return configs

Allow more than one GitHub repo from the same user
Allow more than one GitHub repo from the same user

GitHub does not allow the same SSH key to be used for multiple
repositories on the same server belonging to the same user, see:

http://snipe.net/2013/04/multiple-github-deploy-keys-single-server

The fix there doesn't work because the "url" field is used both to
get the repo and to identify it when a push comes in.  Using a local
SSH name for the repo works for getting the repo but then the name in
the push doesn't match.

This patch adds a 'repo' option that that can be set to the name of
the repo as given in the push.  If 'repo' is not set the behaviour
is unchanged.

Example:

"url": "git@repo-a-shortname/somerepo.git"
"repo": "git@github.com/somerepo.git"
