Exemplo n.º 1
0
def set_release_version(tag):
    print "set libbe.version._VERSION = '%s'" % tag
    invoke([
        'sed', '-i',
        "s/^[# ]*_VERSION *=.*/_VERSION = '%s'/" % tag,
        os.path.join('libbe', 'version.py')
    ])
Exemplo n.º 2
0
def export(target_dir):
    if not target_dir.endswith(os.path.sep):
        target_dir += os.path.sep
    print 'export current revision to', target_dir
    status, stdout, stderr = invoke(
        ['git', 'archive', '--prefix', target_dir, 'HEAD'],
        unicode_output=False)
    status, stdout, stderr = invoke(['tar', '-xv'], stdin=stdout)
Exemplo n.º 3
0
def export(target_dir):
    if not target_dir.endswith(os.path.sep):
        target_dir += os.path.sep
    print 'export current revision to', target_dir
    status,stdout,stderr = invoke(
        ['git', 'archive', '--prefix', target_dir, 'HEAD'],
        unicode_output=False)
    status,stdout,stderr = invoke(['tar', '-xv'], stdin=stdout)
def make_changelog(filename, tag):
    """Generate a ChangeLog from the git history.

    Not the most ChangeLog-esque format, but iterating through commits
    by hand is just too slow.
    """
    print 'generate ChangeLog file', filename, 'up to tag', tag
    invoke(['git', 'log', '--no-merges',
            '%s..%s' % (INITIAL_COMMIT, tag)],
           stdout=open(filename, 'w')),
Exemplo n.º 5
0
def make_changelog(filename, tag):
    """Generate a ChangeLog from the git history.

    Not the most ChangeLog-esque format, but iterating through commits
    by hand is just too slow.
    """
    print 'generate ChangeLog file', filename, 'up to tag', tag
    invoke(['git', 'log', '--no-merges',
            '%s..%s' % (INITIAL_COMMIT, tag)],
           stdout=open(filename, 'w')),
Exemplo n.º 6
0
def set_vcs_name(be_dir, vcs_name='None'):
    """Exported directory is not a git repository, so set vcs_name to
    something that will work.
      vcs_name: new_vcs_name
    """
    for directory in os.listdir(be_dir):
        if not os.path.isdir(os.path.join(be_dir, directory)):
            continue
        filename = os.path.join(be_dir, directory, 'settings')
        if os.path.exists(filename):
            print 'set vcs_name in', filename, 'to', vcs_name
            invoke(['sed', '-i', "s/^vcs_name:.*/vcs_name: %s/" % vcs_name,
                    filename])
Exemplo n.º 7
0
def set_vcs_name(be_dir, vcs_name='None'):
    """Exported directory is not a git repository, so set vcs_name to
    something that will work.
      vcs_name: new_vcs_name
    """
    for directory in os.listdir(be_dir):
        if not os.path.isdir(os.path.join(be_dir, directory)):
            continue
        filename = os.path.join(be_dir, directory, 'settings')
        if os.path.exists(filename):
            print 'set vcs_name in', filename, 'to', vcs_name
            invoke([
                'sed', '-i',
                "s/^vcs_name:.*/vcs_name: %s/" % vcs_name, filename
            ])
Exemplo n.º 8
0
def pending_changes():
    """Use `git diff`s output to detect change.
    """
    status, stdout, stderr = invoke(['git', 'diff', 'HEAD'])
    if len(stdout) == 0:
        return False
    return True
Exemplo n.º 9
0
def pending_changes():
    """Use `git diff`s output to detect change.
    """
    status,stdout,stderr = invoke(['git', 'diff', 'HEAD'])
    if len(stdout) == 0:
        return False
    return True
Exemplo n.º 10
0
 def _u_invoke(self, *args, **kwargs):
     if 'cwd' not in kwargs:
         kwargs['cwd'] = self.repo
     if 'verbose' not in kwargs:
         kwargs['verbose'] = self.verbose_invoke
     if 'encoding' not in kwargs:
         kwargs['encoding'] = self.encoding
     return invoke(*args, **kwargs)
Exemplo n.º 11
0
 def _u_invoke(self, *args, **kwargs):
     if 'cwd' not in kwargs:
         kwargs['cwd'] = self.repo
     if 'verbose' not in kwargs:
         kwargs['verbose'] = self.verbose_invoke
     if 'encoding' not in kwargs:
         kwargs['encoding'] = self.encoding
     return invoke(*args, **kwargs)
def create_tarball(tag):
    release_name = 'be-%s' % tag
    export_dir = release_name
    export(export_dir)
    make_version()
    remove_makefile_libbe_version_dependencies(
        os.path.join(export_dir, 'Makefile'))
    print 'copy libbe/_version.py to %s/libbe/_version.py' % export_dir
    shutil.copy(os.path.join('libbe', '_version.py'),
                os.path.join(export_dir, 'libbe', '_version.py'))
    make_changelog(os.path.join(export_dir, 'ChangeLog'), tag)
    make_id_cache()
    print 'copy .be/id-cache to %s/.be/id-cache' % export_dir
    shutil.copy(os.path.join('.be', 'id-cache'),
                os.path.join(export_dir, '.be', 'id-cache'))
    set_vcs_name(os.path.join(export_dir, '.be'))
    tarball_file = '%s.tar.gz' % release_name
    print 'create tarball', tarball_file
    invoke(['tar', '-czf', tarball_file, export_dir])
    print 'remove', export_dir
    shutil.rmtree(export_dir)
Exemplo n.º 13
0
def create_tarball(tag):
    release_name='be-%s' % tag
    export_dir = release_name
    export(export_dir)
    make_version()
    remove_makefile_libbe_version_dependencies(
        os.path.join(export_dir, 'Makefile'))
    print 'copy libbe/_version.py to %s/libbe/_version.py' % export_dir
    shutil.copy(os.path.join('libbe', '_version.py'),
                os.path.join(export_dir, 'libbe', '_version.py'))
    make_changelog(os.path.join(export_dir, 'ChangeLog'), tag)
    make_id_cache()
    print 'copy .be/id-cache to %s/.be/id-cache' % export_dir
    shutil.copy(os.path.join('.be', 'id-cache'),
                os.path.join(export_dir, '.be', 'id-cache'))
    set_vcs_name(os.path.join(export_dir, '.be'))
    tarball_file = '%s.tar.gz' % release_name
    print 'create tarball', tarball_file
    invoke(['tar', '-czf', tarball_file, export_dir])
    print 'remove', export_dir
    shutil.rmtree(export_dir)
Exemplo n.º 14
0
def make_changelog(filename, tag):
    """Generate a ChangeLog from the git history.

    Not the most ChangeLog-esque format, but iterating through commits
    by hand is just too slow.
    """
    print 'generate ChangeLog file', filename, 'up to tag', tag
    status,stdout,stderr = invoke(
        ['git', 'log', '--no-merges', '{}..{}'.format(INITIAL_COMMIT, tag)])
    with codecs.open(filename, 'w', 'utf-8') as f:
        for line in stdout.splitlines():
            f.write(line.rstrip())
            f.write(u'\n')
Exemplo n.º 15
0
def make_changelog(filename, tag):
    """Generate a ChangeLog from the git history.

    Not the most ChangeLog-esque format, but iterating through commits
    by hand is just too slow.
    """
    print 'generate ChangeLog file', filename, 'up to tag', tag
    status, stdout, stderr = invoke(
        ['git', 'log', '--no-merges', '{}..{}'.format(INITIAL_COMMIT, tag)])
    with codecs.open(filename, 'w', 'utf-8') as f:
        for line in stdout.splitlines():
            f.write(line.rstrip())
            f.write(u'\n')
Exemplo n.º 16
0
def main(*args, **kwargs):
    usage = """%prog [options] TAG

Create a git tag and a release tarball from the current revision.
For example
  %prog 1.0.0

If you don't like what got committed, you can undo the release with
  $ git tag -d 1.0.0
  $ git reset --hard HEAD^
"""
    p = optparse.OptionParser(usage)
    p.add_option('--test',
                 dest='test',
                 default=False,
                 action='store_true',
                 help='Run internal tests and exit')
    options, args = p.parse_args(*args, **kwargs)

    if options.test == True:
        test()
        sys.exit(0)

    assert len(args) == 1, '%d (!= 1) arguments: %s' % (len(args), args)
    _tag = args[0]
    validate_tag(_tag)

    if pending_changes() == True:
        print "Handle pending changes before releasing."
        sys.exit(1)
    set_release_version(_tag)
    print "Update copyright information..."
    env = dict(os.environ)
    pythonpath = os.path.abspath('update-copyright')
    if 'PYTHONPATH' in env:
        env['PYTHONPATH'] = '{}:{}'.format(pythonpath, env['PYTHONPATH'])
    else:
        env['PYTHONPATH'] = pythonpath
    status, stdout, stderr = invoke(
        [os.path.join('update-copyright', 'bin', 'update-copyright.py')],
        env=env)
    commit("Bumped to version %s" % _tag)
    tag(_tag)
    create_tarball(_tag)
Exemplo n.º 17
0
def main(*args, **kwargs):
    usage = """%prog [options] TAG

Create a git tag and a release tarball from the current revision.
For example
  %prog 1.0.0

If you don't like what got committed, you can undo the release with
  $ git tag -d 1.0.0
  $ git reset --hard HEAD^
"""
    p = optparse.OptionParser(usage)
    p.add_option('--test', dest='test', default=False,
                 action='store_true', help='Run internal tests and exit')
    options,args = p.parse_args(*args, **kwargs)

    if options.test == True:
        test()
        sys.exit(0)

    assert len(args) == 1, '%d (!= 1) arguments: %s' % (len(args), args)
    _tag = args[0]
    validate_tag(_tag)

    if pending_changes() == True:
        print "Handle pending changes before releasing."
        sys.exit(1)
    set_release_version(_tag)
    print "Update copyright information..."
    env = dict(os.environ)
    pythonpath = os.path.abspath('update-copyright')
    if 'PYTHONPATH' in env:
        env['PYTHONPATH'] = '{}:{}'.format(pythonpath, env['PYTHONPATH'])
    else:
        env['PYTHONPATH'] = pythonpath
    status,stdout,stderr = invoke([
            os.path.join('update-copyright', 'bin', 'update-copyright.py')],
            env=env)
    commit("Bumped to version %s" % _tag)
    tag(_tag)
    create_tarball(_tag)
Exemplo n.º 18
0
def commit(commit_message):
    print 'commit current status:', commit_message
    invoke(['git', 'commit', '-a', '-m', commit_message])
Exemplo n.º 19
0
def remove_makefile_libbe_version_dependencies(filename):
    print "set %s LIBBE_VERSION :=" % filename
    invoke(['sed', '-i', "s/^LIBBE_VERSION *:=.*/LIBBE_VERSION :=/",
            filename])
Exemplo n.º 20
0
def set_release_version(tag):
    print "set libbe.version._VERSION = '%s'" % tag
    invoke(['sed', '-i', "s/^[# ]*_VERSION *=.*/_VERSION = '%s'/" % tag,
            os.path.join('libbe', 'version.py')])
Exemplo n.º 21
0
def tag(tag):
    print 'tag current revision', tag
    invoke(['git', 'tag', tag])
def tag(tag):
    print 'tag current revision', tag
    invoke(['git', 'tag', tag])
Exemplo n.º 23
0
def make_version():
    print 'generate libbe/_version.py'
    invoke(['make', os.path.join('libbe', '_version.py')])
Exemplo n.º 24
0
def make_version():
    print 'generate libbe/_version.py'
    invoke(['make', os.path.join('libbe', '_version.py')])
Exemplo n.º 25
0
def make_html_docs(docdir):
    """Generate docs so users won't need to install Sphinx, etc.
    """
    print('generate HTML docs in {}'.format(docdir))
    status, stdout, stderr = invoke(
        ['make', 'SPHINXBUILD=sphinx-build-2.7', 'dirhtml'], cwd=docdir)
Exemplo n.º 26
0
def tag(tag):
    print 'tag current revision', tag
    invoke(['git', 'tag', '-s', '-m', 'version {}'.format(tag), tag])
Exemplo n.º 27
0
def commit(commit_message):
    print 'commit current status:', commit_message
    invoke(['git', 'commit', '-a', '-m', commit_message])
Exemplo n.º 28
0
def remove_makefile_libbe_version_dependencies(filename):
    print "set %s LIBBE_VERSION :=" % filename
    invoke(['sed', '-i', "s/^LIBBE_VERSION *:=.*/LIBBE_VERSION :=/", filename])
Exemplo n.º 29
0
    p = optparse.OptionParser(usage)
    p.add_option('--test', dest='test', default=False,
                 action='store_true', help='Run internal tests and exit')
    options,args = p.parse_args()

    if options.test == True:
        test()
        sys.exit(0)

    assert len(args) == 1, '%d (!= 1) arguments: %s' % (len(args), args)
    _tag = args[0]
    validate_tag(_tag)

    if pending_changes() == True:
        print "Handle pending changes before releasing."
        sys.exit(1)
    set_release_version(_tag)
    print "Update copyright information..."
    env = dict(os.environ)
    pythonpath = os.path.abspath('update-copyright')
    if 'PYTHONPATH' in env:
        env['PYTHONPATH'] = '{}:{}'.format(pythonpath, env['PYTHONPATH'])
    else:
        env['PYTHONPATH'] = pythonpath
    status,stdout,stderr = invoke([
            os.path.join('update-copyright', 'bin', 'update-copyright.py')],
            env=env)
    commit("Bumped to version %s" % _tag)
    tag(_tag)
    create_tarball(_tag)
Exemplo n.º 30
0
def tag(tag):
    print 'tag current revision', tag
    invoke(['git', 'tag', '-s', '-m', 'version {}'.format(tag), tag])
Exemplo n.º 31
0
def make_id_cache():
    """Generate .be/id-cache so users won't need to.
    """
    invoke([sys.executable, './be', 'list'])
Exemplo n.º 32
0
def make_id_cache():
    """Generate .be/id-cache so users won't need to.
    """
    invoke([sys.executable, './be', 'list'])
                 default=False,
                 action='store_true',
                 help='Run internal tests and exit')
    options, args = p.parse_args()

    if options.test == True:
        test()
        sys.exit(0)

    assert len(args) == 1, '%d (!= 1) arguments: %s' % (len(args), args)
    _tag = args[0]
    validate_tag(_tag)

    if pending_changes() == True:
        print "Handle pending changes before releasing."
        sys.exit(1)
    set_release_version(_tag)
    print "Update copyright information..."
    env = dict(os.environ)
    pythonpath = os.path.abspath('update-copyright')
    if 'PYTHONPATH' in env:
        env['PYTHONPATH'] = '{}:{}'.format(pythonpath, env['PYTHONPATH'])
    else:
        env['PYTHONPATH'] = pythonpath
    status, stdout, stderr = invoke(
        [os.path.join('update-copyright', 'bin', 'update-copyright.py')],
        env=env)
    commit("Bumped to version %s" % _tag)
    tag(_tag)
    create_tarball(_tag)
Exemplo n.º 34
0
def make_html_docs(docdir):
    """Generate docs so users won't need to install Sphinx, etc.
    """
    print('generate HTML docs in {}'.format(docdir))
    status,stdout,stderr = invoke(
        ['make', 'SPHINXBUILD=sphinx-build-2.7', 'dirhtml'], cwd=docdir)