def repository_url(datastore_client, name):
    """Returns the URL of a repository, given its short name.

    If a repository moved locations or has multiple locations, a repository can
    have multiple URLs. The returned URL should be the current canonical one.

    Args:
      datastore_client: The client to use for the datastore query.
      name: The short name of the repository.

    Returns:
      A URL string, not including '.git'.
    """
    repositories = datastore_client.query(kind='Repository',
                                          order=('-time_added', ),
                                          filters=(('name', '=',
                                                    name), )).fetch()
    for repo in repositories:
        return repo['url']
    raise KeyError(f'Unknown repository name: {name}')