コード例 #1
0
ファイル: cli.py プロジェクト: bmcorser/changes
def main(context, module_name, dry_run, debug, no_input, requirements, patch, minor, major, version_prefix):
    """Ch-ch-changes"""

    logging.basicConfig(level=logging.DEBUG if debug else logging.INFO)

    new_version = version.get_new_version(
        module_name,
        version.current_version(module_name),
        no_input, major, minor, patch,
    )

    current_version = version.current_version(module_name)
    repo_url = attributes.extract_attribute(module_name, '__url__')
    context.obj = config.Changes(module_name, dry_run, debug, no_input, requirements, new_version, current_version, repo_url, version_prefix)

    probe.probe_project(context.obj)
コード例 #2
0
ファイル: changelog.py プロジェクト: bossjones/changes
def replace_sha_with_commit_link(git_log_content):
    repo_url = attributes.extract_attribute(config.common_arguments()[0],
                                            '__url__')

    for index, line in enumerate(git_log_content):
        # http://stackoverflow.com/a/468378/5549
        sha1_re = re.match(r'^[0-9a-f]{5,40}\b', line)
        if sha1_re:
            sha1 = sha1_re.group()

            new_line = line.replace(
                sha1, '[%s](%s/commit/%s)' % (sha1, repo_url, sha1))
            log.debug('old line: %s\nnew line: %s', line, new_line)
            git_log_content[index] = new_line

    return git_log_content
コード例 #3
0
ファイル: changelog.py プロジェクト: Sureiya/changes
def changelog():
    module_name, dry_run, new_version = config.common_arguments()

    changelog_content = [
        '\n## [%s](%s/compare/%s...%s)\n\n' % (
            new_version, attributes.extract_attribute(module_name, '__url__'),
            version.current_version(module_name), new_version,
        )
    ]

    git_log_content = None
    try:
        git_log_content = sh.git.log(
            '--oneline',
            '--no-merges',
            '%s..master' % version.current_version(module_name),
            _tty_out=False
        ).split('\n')
        log.debug('content: %s' % git_log_content)
    except:
        log.warn('Error diffing previous version, initial release')

        git_log_content = sh.git.log(
            '--oneline',
            '--no-merges',
            _tty_out=False
        ).split('\n')

    git_log_content = replace_sha_with_commit_link(git_log_content)

    log.debug('content: %s' % git_log_content)

    # makes change log entries into bullet points
    if git_log_content:
        [
            changelog_content.append('* %s\n' % line)
            if line else line
            for line in git_log_content[:-1]
        ]

    write_new_changelog(
        module_name,
        config.CHANGELOG,
        changelog_content,
        dry_run=dry_run
    )
    log.info('Added content to CHANGELOG.md')
コード例 #4
0
ファイル: changelog.py プロジェクト: bossjones/changes
def changelog():
    module_name, dry_run, new_version = config.common_arguments()

    changelog_content = [
        '\n## [%s](%s/compare/%s...%s)\n\n' % (
            new_version,
            attributes.extract_attribute(module_name, '__url__'),
            version.current_version(module_name),
            new_version,
        )
    ]

    git_log_content = None
    try:
        git_log_content = sh.git.log('--oneline',
                                     '--no-merges',
                                     '%s..master' %
                                     version.current_version(module_name),
                                     _tty_out=False).split('\n')
        log.debug('content: %s' % git_log_content)
    except:
        log.warn('Error diffing previous version, initial release')

        git_log_content = sh.git.log('--oneline',
                                     '--no-merges',
                                     _tty_out=False).split('\n')

    git_log_content = replace_sha_with_commit_link(git_log_content)

    log.debug('content: %s' % git_log_content)

    # makes change log entries into bullet points
    if git_log_content:
        [
            changelog_content.append('* %s\n' % line) if line else line
            for line in git_log_content[:-1]
        ]

    write_new_changelog(module_name,
                        config.CHANGELOG,
                        changelog_content,
                        dry_run=dry_run)
    log.info('Added content to CHANGELOG.md')
コード例 #5
0
ファイル: changelog.py プロジェクト: Sureiya/changes
def replace_sha_with_commit_link(git_log_content):
    repo_url = attributes.extract_attribute(
        config.common_arguments()[0],
        '__url__'
    )

    for index, line in enumerate(git_log_content):
        # http://stackoverflow.com/a/468378/5549
        sha1_re = re.match(r'^[0-9a-f]{5,40}\b', line)
        if sha1_re:
            sha1 = sha1_re.group()

            new_line = line.replace(
                sha1,
                '[%s](%s/commit/%s)' % (sha1, repo_url, sha1)
            )
            log.debug('old line: %s\nnew line: %s', line, new_line)
            git_log_content[index] = new_line

    return git_log_content
コード例 #6
0
ファイル: cli.py プロジェクト: michaelaye/changes
def main(context, module_name, dry_run, debug, no_input, requirements, patch,
         minor, major, version_prefix):
    """Ch-ch-changes"""

    logging.basicConfig(level=logging.DEBUG if debug else logging.INFO)

    new_version = version.get_new_version(
        module_name,
        version.current_version(module_name),
        no_input,
        major,
        minor,
        patch,
    )

    current_version = version.current_version(module_name)
    repo_url = attributes.extract_attribute(module_name, '__url__')
    context.obj = config.CLI(module_name, dry_run, debug, no_input,
                             requirements, new_version, current_version,
                             repo_url, version_prefix)

    probe.probe_project(context.obj)
コード例 #7
0
ファイル: changelog.py プロジェクト: bossjones/changes
def write_new_changelog(module_name, filename, content_lines, dry_run=True):
    heading_and_newline = (
        '# [Changelog](%s/releases)\n' %
        attributes.extract_attribute(module_name, '__url__'))

    with open(filename, 'r+') as f:
        existing = f.readlines()

    output = existing[2:]
    output.insert(0, '\n')

    for index, line in enumerate(content_lines):
        output.insert(0, content_lines[len(content_lines) - index - 1])

    output.insert(0, heading_and_newline)

    output = ''.join(output)

    if not dry_run:
        with open(filename, 'w+') as f:
            f.write(output)
    else:
        log.info('New changelog:\n%s', ''.join(content_lines))
コード例 #8
0
ファイル: changelog.py プロジェクト: Sureiya/changes
def write_new_changelog(module_name, filename, content_lines, dry_run=True):
    heading_and_newline = (
        '# [Changelog](%s/releases)\n' %
        attributes.extract_attribute(module_name, '__url__')
    )

    with open(filename, 'r+') as f:
        existing = f.readlines()

    output = existing[2:]
    output.insert(0, '\n')

    for index, line in enumerate(content_lines):
        output.insert(0, content_lines[len(content_lines) - index - 1])

    output.insert(0, heading_and_newline)

    output = ''.join(output)

    if not dry_run:
        with open(filename, 'w+') as f:
            f.write(output)
    else:
        log.info('New changelog:\n%s', ''.join(content_lines))
コード例 #9
0
def current_version(module_name):
    return attributes.extract_attribute(module_name, '__version__')
コード例 #10
0
def test_extract_attribute(python_module):
    assert '0.0.1' == attributes.extract_attribute('test_app', '__version__')
コード例 #11
0
def test_extract_attribute(python_module):
    assert '0.0.1' == attributes.extract_attribute('test_app', '__version__')
コード例 #12
0
ファイル: version.py プロジェクト: henrywm/changes
def current_version(module_name):
    return attributes.extract_attribute(module_name, '__version__')
コード例 #13
0
ファイル: test_attributes.py プロジェクト: Sureiya/changes
 def test_extract_attribute(self):
     self.assertEquals(
         '0.0.1',
         attributes.extract_attribute('test_app', '__version__')
     )
コード例 #14
0
 def test_extract_attribute(self):
     self.assertEquals(
         '0.0.1', attributes.extract_attribute('test_app', '__version__'))