Пример #1
0
def json(ctx):
    if os.name == 'nt':
        ctx.obj['location'] = r'{}'.format(ctx.obj['location'])

    if "github" in get_repo_url_info(location=ctx.obj['location'],
                                     repo_url=ctx.obj['repo_url']).resource:
        click.echo('GitHub detected. \n')

        github(force=True,
               token=ctx.obj['token'],
               location=ctx.obj['location'],
               repo_url=ctx.obj['repo_url'],
               file_type='json').write_json()

    elif "gitlab" in get_repo_url_info(location=ctx.obj['location'],
                                       repo_url=ctx.obj['repo_url']).resource:
        click.echo('GitLab detected. \n')

        gitlab(force=True,
               token=ctx.obj['token'],
               location=ctx.obj['location'],
               repo_url=ctx.obj['repo_url'],
               file_type='json').write_json()

    else:
        raise UnknownRepo(
            "Sorry, couldn't find the repository. Trying giving the repository URL by adding --url flag."
        )
Пример #2
0
def markdown(ctx):
    if os.name == 'nt':
        ctx.obj['location'] = rf"{ctx.obj['location']}"

    if "github" in get_repo_url_info(location=ctx.obj['location'],
                                     repo_url=ctx.obj['repo_url']).resource:
        print('GitHub detected. \n')

        github(force=True,
               token=ctx.obj['token'],
               location=ctx.obj['location'],
               repo_url=ctx.obj['repo_url'],
               file_type='markdown').write()

    elif "gitlab" in get_repo_url_info(location=ctx.obj['location'],
                                       repo_url=ctx.obj['repo_url']).resource:
        print('GitLab detected. \n')

        gitlab(force=True,
               token=ctx.obj['token'],
               location=ctx.obj['location'],
               repo_url=ctx.obj['repo_url'],
               file_type='markdown').write()

    else:
        raise UnknownRepo(
            "Sorry, couldn't find the repository. Trying giving the repository URL by adding --url flag."
        )
Пример #3
0
    def __init__(self, *args, **kwargs):
        super(GitLabRequest, self).__init__(*args, **kwargs)
        self.request_headers = {'Private-Token': '%s' % self.token}
        self.api_url = 'https://gitlab.com/api/v4/'

        if self.token is None:
            raise InvalidToken(
                "Oops! GitLab requires you to generate a private token to get the details. See "
                "https://docs.gitlab.com/ce/user/profile/personal_access_tokens.html "
                "for more information.")

        if self.repo_url is not None:
            self.info = get_repo_url_info(self.location, repo_url=self.repo_url)
        else:
            self.info = get_repo_url_info(self.location)
Пример #4
0
    def __init__(self, *args, **kwargs):
        super(GitHubRequest, self).__init__(*args, **kwargs)
        self.request_headers = {'Authorization': 'token %s' % self.token}
        self.api_url = 'https://api.github.com/graphql'

        if self.token is None:
            raise InvalidToken(
                "Oops! GitHub requires you to generate a private token to get the details. See "
                "https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ "
                "for more information.")

        if self.repo_url is not None:
            self.info = get_repo_url_info(self.location, repo_url=self.repo_url)
        else:
            self.info = get_repo_url_info(self.location)
Пример #5
0
def test_get_repo_url_info_fail_2():
    t = tempfile.gettempdir()
    temp_file(DUP_SECTION)

    with pytest.raises(configparser.DuplicateSectionError,
                       message='There seems to be a duplicate section in your config. Try giving the repository URL by using --url.'):
        content = get_repo_url_info(location=t)
Пример #6
0
def test_get_repo_url_info_pass():
    t = tempfile.gettempdir()
    temp_file(PASS_SECTION)

    content = get_repo_url_info(location=t)

    assert content.owner == 'akshaybabloo'
Пример #7
0
def test_get_repo_url_info_fail():
    with pytest.raises(
            ParserError,
            message=
            'Git config file does not exist please provide the repository url by using --url.'
    ):
        content = get_repo_url_info(location='yo')
Пример #8
0
def all_format(ctx):
    if os.name == 'nt':
        ctx.obj['location'] = rf"{ctx.obj['location']}"

    if "github" in get_repo_url_info(location=ctx.obj['location'],
                                     repo_url=ctx.obj['repo_url']).resource:
        # Creates for GitHub
        print("Creating change logs for GitHub.")
        github(force=True,
               token=ctx.obj['token'],
               location=ctx.obj['location'],
               repo_url=ctx.obj['repo_url'],
               file_type='json').write()
        github(force=True,
               token=ctx.obj['token'],
               location=ctx.obj['location'],
               repo_url=ctx.obj['repo_url'],
               file_type='markdown').write()
        # github(force=True, token=ctx.obj['token'], location=ctx.obj['location'], repo_url=ctx.obj['repo_url'],
        #        file_type='rst').write()
    else:
        # Creates for GitLab
        print("Creating change logs for GitLab.")
        gitlab(force=True,
               token=ctx.obj['token'],
               location=ctx.obj['location'],
               repo_url=ctx.obj['repo_url'],
               file_type='json').write()
        gitlab(force=True,
               token=ctx.obj['token'],
               location=ctx.obj['location'],
               repo_url=ctx.obj['repo_url'],
               file_type='markdown').write()
Пример #9
0
def test_get_repo_url_info_args():
    content = get_repo_url_info(
        repo_url='https://github.com/akshaybabloo/release-exporter.git')

    assert parse(
        'https://github.com/akshaybabloo/release-exporter.git').owner == content.owner