How to use bloom - 10 common examples

To help you get started, we’ve selected a few bloom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ros-infrastructure / bloom / bloom / generators / release.py View on Github external
from bloom.packages import get_package_data

from bloom.util import execute_command

from bloom.commands.git.patch.trim_cmd import trim

try:
    import catkin_pkg
    from pkg_resources import parse_version
    if parse_version(catkin_pkg.__version__) < parse_version('0.3.8'):
        warning("This version of bloom requires catkin_pkg version >= '0.3.8',"
                " the used version of catkin_pkg is '{0}'".format(catkin_pkg.__version__))
    from catkin_pkg import metapackage
except ImportError as err:
    debug(traceback.format_exc())
    error("catkin_pkg was not detected, please install it.", exit=True)


class ReleaseGenerator(BloomGenerator):
    title = 'release'
    description = """\
Generates a release branch for each of the packages in the source branch.
The common use case for this generator is to produce release/* branches for
each package in the upstream repository, so the source branch should be set to
'upstream' and the prefix set to 'release'.
"""

    def prepare_arguments(self, parser):
        # Add command line arguments for this generator
        add = parser.add_argument
        add('-s', '--src', '--source-branch', default=None, dest='src',
github ros-infrastructure / bloom / test / system_tests / test_catkin_release.py View on Github external
cmd = 'git-bloom-release{0} melodic'
            if 'BLOOM_VERBOSE' not in os.environ:
                cmd = cmd.format(' --quiet')
            else:
                cmd = cmd.format('')
            user(cmd, silent=False)
        ###
        ### Import upstream
        ###
        # does the upstream branch exist?
        assert branch_exists('upstream', local_only=True), "no upstream branch"
        # does the upstrea/ tag exist?
        ret, out, err = user('git tag', return_io=True)
        assert out.count('upstream/' + version) == 1, "no upstream tag created"
        # Is the package.xml from upstream in the upstream branch now?
        with inbranch('upstream'):
            assert os.path.exists('package.xml'), \
                "upstream did not import: '" + os.getcwd() + "': " + \
                str(os.listdir(os.getcwd()))
            assert os.path.exists(os.path.join('debian', 'something.udev')), \
                "Lost the debian overlaid files in upstream branch"
            assert os.path.exists('white space.txt~'), \
                "Lost file with whitespace in name in upstream branch"
            with open('package.xml') as f:
                package_xml = f.read()
                assert package_xml.count(version), "not right file"

        ###
        ### Release generator
        ###
        # patch import should have reported OK
        assert ret == code.OK, "actually returned ({0})".format(ret)
github ros-infrastructure / bloom / test / system_tests / test_catkin_release.py View on Github external
assert ret == code.OK, "actually returned ({0})".format(ret)
        # do the proper branches exist?
        assert branch_exists('release/melodic/foo'), \
            "no release/melodic/foo branch"
        assert branch_exists('patches/release/melodic/foo'), \
            "no patches/release/melodic/foo branch"
        # was the release tag created?
        ret, out, err = user('git tag', return_io=True)
        expected = 'release/melodic/foo/' + version + '-1'
        assert out.count(expected) == 1, \
            "no release tag created, expected: '{0}'".format(expected)

        ###
        ### Make patch
        ###
        with inbranch('release/melodic/foo'):
            assert os.path.exists(os.path.join('debian', 'something.udev')), \
                "Lost the debian overlaid files in release branch"
            assert os.path.exists('white space.txt~'), \
                "Lost file with whitespace in name in release branch"
            assert os.path.islink('include/sym/foo.h'), "Symbolic link lost during pipeline"
            if os.path.exists('include/foo.h'):
                user('git rm include/foo.h')
            else:
                if not os.path.exists('include'):
                    os.makedirs('include')
                user('touch include/foo.h')
                user('git add include/foo.h')
            user('git commit -m "A release patch" --allow-empty')

        ###
        ### Test import and export
github ros-infrastructure / bloom / test / system_tests / test_catkin_fuerte_release.py View on Github external
assert branch_exists('release/fuerte/foo'), \
            "no release/foo branch: " + str(get_branches())
        assert branch_exists('patches/release/fuerte/foo'), \
            "no patches/release/foo branch"
        # was the release tag created?
        ret, out, err = user('git tag', return_io=True)
        assert out.count('release/fuerte/foo/0.1.0') == 1, \
            "no release tag created"

        ###
        ### Release generator, again
        ###
        # patch import should have reported OK
        assert ret == code.OK, "actually returned ({0})".format(ret)
        # do the proper branches exist?
        assert branch_exists('release/fuerte/foo'), \
            "no release/foo branch: " + str(get_branches())
        assert branch_exists('patches/release/fuerte/foo'), \
            "no patches/release/fuerte/foo branch"
        # was the release tag created?
        ret, out, err = user('git tag', return_io=True)
        assert out.count('release/fuerte/foo/0.1.0') == 1, \
            "no release tag created"
github ros-infrastructure / bloom / test / system_tests / test_catkin_release.py View on Github external
"Lost the debian overlaid files in upstream branch"
            assert os.path.exists('white space.txt~'), \
                "Lost file with whitespace in name in upstream branch"
            with open('package.xml') as f:
                package_xml = f.read()
                assert package_xml.count(version), "not right file"

        ###
        ### Release generator
        ###
        # patch import should have reported OK
        assert ret == code.OK, "actually returned ({0})".format(ret)
        # do the proper branches exist?
        assert branch_exists('release/melodic/foo'), \
            "no release/melodic/foo branch"
        assert branch_exists('patches/release/melodic/foo'), \
            "no patches/release/melodic/foo branch"
        # was the release tag created?
        ret, out, err = user('git tag', return_io=True)
        expected = 'release/melodic/foo/' + version + '-1'
        assert out.count(expected) == 1, \
            "no release tag created, expected: '{0}'".format(expected)

        ###
        ### Make patch
        ###
        with inbranch('release/melodic/foo'):
            assert os.path.exists(os.path.join('debian', 'something.udev')), \
                "Lost the debian overlaid files in release branch"
            assert os.path.exists('white space.txt~'), \
                "Lost file with whitespace in name in release branch"
            assert os.path.islink('include/sym/foo.h'), "Symbolic link lost during pipeline"
github ros-infrastructure / bloom / test / test_bloom_git.py View on Github external
from bloom.util import check_output
    check_call('git init .', shell=True, cwd=orig_dir, stdout=PIPE)
    check_call('touch example.txt', shell=True, cwd=orig_dir, stdout=PIPE)
    check_call('git add *', shell=True, cwd=orig_dir, stdout=PIPE)
    check_call('git commit -m "Init"', shell=True, cwd=orig_dir, stdout=PIPE)
    check_call('git branch bloom', shell=True, cwd=orig_dir, stdout=PIPE)
    check_call('git branch upstream', shell=True, cwd=orig_dir, stdout=PIPE)
    check_call('git branch refactor', shell=True, cwd=orig_dir, stdout=PIPE)
    from vcstools import VcsClient
    clone = VcsClient('git', clone_dir)
    clone.checkout('file://{0}'.format(orig_dir), 'master')
    output = check_output('git branch --no-color', shell=True, cwd=clone_dir)
    assert output == '* master\n'
    from bloom.git import track_branches
    track_branches(['bloom', 'upstream'], clone_dir)
    output = check_output('git branch --no-color', shell=True, cwd=clone_dir)
    assert output == '  bloom\n* master\n  upstream\n', \
           '\n' + str(output) + '\n == \n' + '  bloom\n* master\n  upstream\n'
    track_branches(directory=clone_dir)
    output = check_output('git branch --no-color', shell=True, cwd=clone_dir)
    assert output == '  bloom\n* master\n  refactor\n  upstream\n', \
           output + ' == `  bloom\n* master\n  refactor\n  upstream\n`'
    track_branches(['fake'], clone_dir)
    output = check_output('git branch', shell=True, cwd=clone_dir)
    assert output.count('fake') == 0
    rmtree(tmp_dir)
github ros-infrastructure / bloom / test / test_bloom_git.py View on Github external
def test_show():
    tmp_dir, git_dir = create_git_repo()
    from bloom.git import show
    assert show('master', 'something.txt') == None
    with open(os.path.join(git_dir, 'something.txt'), 'w+') as f:
        f.write('v1\n')
    assert show('master', 'something.txt') == None
    check_call('git add something.txt', shell=True, cwd=git_dir,
               stdout=PIPE)
    check_call('git commit -am "added something.txt"', shell=True, cwd=git_dir,
               stdout=PIPE)
    assert show('master', 'something.txt', git_dir) == 'v1\n', \
           str(show('master', 'something.txt', git_dir)) + ' == v1'
    os.makedirs(os.path.join(git_dir, 'adir'))
    copy(os.path.join(git_dir, 'something.txt'), os.path.join(git_dir, 'adir'))
    with open(os.path.join(git_dir, 'adir', 'something.txt'), 'a') as f:
        f.write('v2\n')
    check_call('git add adir', shell=True, cwd=git_dir,
               stdout=PIPE)
    check_call('git commit -am "made a subfolder"', shell=True, cwd=git_dir,
github ros-infrastructure / bloom / test / test_bloom_git.py View on Github external
check_call('git branch refactor', shell=True, cwd=orig_dir, stdout=PIPE)
    from vcstools import VcsClient
    clone = VcsClient('git', clone_dir)
    clone.checkout('file://{0}'.format(orig_dir), 'master')
    output = check_output('git branch --no-color', shell=True, cwd=clone_dir)
    assert output == '* master\n'
    from bloom.git import track_branches
    track_branches(['bloom', 'upstream'], clone_dir)
    output = check_output('git branch --no-color', shell=True, cwd=clone_dir)
    assert output == '  bloom\n* master\n  upstream\n', \
           '\n' + str(output) + '\n == \n' + '  bloom\n* master\n  upstream\n'
    track_branches(directory=clone_dir)
    output = check_output('git branch --no-color', shell=True, cwd=clone_dir)
    assert output == '  bloom\n* master\n  refactor\n  upstream\n', \
           output + ' == `  bloom\n* master\n  refactor\n  upstream\n`'
    track_branches(['fake'], clone_dir)
    output = check_output('git branch', shell=True, cwd=clone_dir)
    assert output.count('fake') == 0
    rmtree(tmp_dir)
github ros-infrastructure / bloom / test / unit_tests / test_packages.py View on Github external
def test_get_package_data_fails_on_uppercase():
    user('git init .')

    with AssertRaisesContext(SystemExit, "Invalid package names, aborting."):
        with redirected_stdio():
            get_package_data(directory=test_data_dir)
github ros-infrastructure / bloom / bloom / generators / debian / generator.py View on Github external
error("")
        if not maybe_continue('n', 'Continue anyways'):
            sys.exit("User quit.")
    data['changelogs'] = changelogs
    # Use debhelper version 7 for oneric, otherwise 9
    data['debhelper_version'] = 7 if os_version in ['oneiric'] else 9
    # Summarize dependencies
    summarize_dependency_mapping(data, depends, build_depends, resolved_deps)
    # Copyright
    licenses = []
    separator = '\n' + '=' * 80 + '\n\n'
    for l in package.licenses:
        if hasattr(l, 'file') and l.file is not None:
            license_file = os.path.join(os.path.dirname(package.filename), l.file)
            if not os.path.exists(license_file):
                error("License file '{}' is not found.".
                      format(license_file), exit=True)
            license_text = open(license_file, 'r').read()
            if not license_text.endswith('\n'):
                license_text += '\n'
            licenses.append(license_text)
    data['Copyright'] = separator.join(licenses)

    def convertToUnicode(obj):
        if sys.version_info.major == 2:
            if isinstance(obj, str):
                return unicode(obj.decode('utf8'))
            elif isinstance(obj, unicode):
                return obj
        else:
            if isinstance(obj, bytes):
                return str(obj.decode('utf8'))