示例#1
0
def update_version_and_merge_for_component(component, opts):
    project_dir = builder.clone_branch(component)

    try:
        git_branch = promote.get_current_git_upstream_branch(project_dir)
        parent_branch = component.get('parent_branch')
    except subprocess.CalledProcessError:
        # most likely, git branch is a tag. In that event, there's nothing to update or
        # merge forward. The script was either called with the wrong release config, or is
        # being used as an expedient to check out the git repos for a given release config.
        # Either way, nothing can be done with this branch.
        print(("Unable to determine git branch for git repo in {}, HEAD is probably a tag."
               " Moving to next component.").format(project_dir))
        return

    if opts.update_version:
        if git_branch.endswith('-release'):
            # Even if update_version was requested, the only way versions should get updated on an
            # x.y-release branch is through the merging of a released tag.
            print("Not updating version on release branch, only merging branches forward.")
        else:
            promotion_chain = promote.get_promotion_chain(project_dir, git_branch,
                                                          parent_branch=parent_branch)
            promote.check_merge_forward(project_dir, promotion_chain)
            update_version = os.path.join(CI_DIR, 'update-version.py')
            # Update the version to the one specified in the config
            command = ['./update-version.py', '--version', component['version'], project_dir]
            subprocess.call(command, cwd=CI_DIR)
            command = ['git', 'commit', '-a', '-m', 'Bumping version to %s' % component['version']]
            subprocess.call(command, cwd=project_dir)
            if opts.push:
                command = ['git', 'push', '-v']
                subprocess.call(command, cwd=project_dir)
    else:
        print("Skipping version update, only merging branches forward.")
    promote.merge_forward(project_dir, push=opts.push, parent_branch=parent_branch)
示例#2
0
source_branch = opts.source_branch
target_branch = opts.target_branch
remote_name = opts.remote_name

print "DANGER ARE YOU SURE YOU WANT TO DO THIS??"
print "All the branches between %s and master will be checked out and pulled." \
      "The results of the promotion will be merged forward to master using '-s ours'."
print "%s and %s will be merged, and updated.  You will be responsible to push to github" % \
      (source_branch, target_branch)
confirmation = raw_input("Are you sure (y/n): ")
if confirmation != 'y':
    print "you thought better, probably a smart move"

print "Checking that we can merge cleanly to master"
# Checkout all the branches required to update & merge forward
promotion_chain = promote.get_promotion_chain(git_directory, target_branch,
                                              upstream_name=remote_name)
promote.check_merge_forward(git_directory, promotion_chain)


print "Getting all the branches required, and pulling the latest version"
for git_branch in promotion_chain:
    promote.checkout_branch(git_directory, git_branch, remote_name=remote_name)

# Update the version on source and merge up
print "Bumping the stage on source before merging to target"
promote.checkout_branch(git_directory, source_branch, remote_name=remote_name)
subprocess.check_call(['./update-version.py', '--update-type', 'stage', git_directory],
                      cwd=current_directory)

new_version = builder.get_nvr_from_spec_file_in_directory(git_directory)
msg = "bumped version to %s" % new_version
示例#3
0
    builder.wait_for_completion(build_ids)

    if opts.release:
        print "Performing koji release build"
        # Clean out the tito dir first
        builder.ensure_dir(TITO_DIR)
        spec_dir_set = set()
        for spec, dist in build_list:
            spec_dir = os.path.dirname(spec)
            if spec_dir not in spec_dir_set:
                spec_dir_set.add(spec_dir)
                # make sure we are clean to merge forward before tagging
                print "validating merge forward for %s" % spec_dir
                git_branch = promote.get_current_git_upstream_branch(spec_dir)
                parent_branch = component.get('parent_branch', None)
                promotion_chain = promote.get_promotion_chain(spec_dir, git_branch, parent_branch=parent_branch)
                promote.check_merge_forward(spec_dir, promotion_chain)
                # Tito tag the new releases
                command = ['tito', 'tag', '--keep-version', '--no-auto-changelog']
                subprocess.check_call(command, cwd=spec_dir)
            builder.build_srpm_from_spec(spec_dir, TITO_DIR, testing=False, dist=dist)

        build_ids = builder.build_with_koji(build_tag_prefix=opts.koji_prefix,
                                            srpm_dir=TITO_DIR, scratch=False)
        builder.wait_for_completion(build_ids)
        for spec_dir in spec_dir_set:
            # Push the tags
            command = ['git', 'push']
            subprocess.check_call(command, cwd=spec_dir)
            command = ['git', 'push', '--tag']
            subprocess.check_call(command, cwd=spec_dir)
示例#4
0
target_branch = opts.target_branch
remote_name = opts.remote_name

print "DANGER ARE YOU SURE YOU WANT TO DO THIS??"
print "All the branches between %s and master will be checked out and pulled." "The results of the promotion will be merged forward to master using '-s ours'."
print "%s and %s will be merged, and updated.  You will be responsible to push to github" % (
    source_branch,
    target_branch,
)
confirmation = raw_input("Are you sure (y/n): ")
if confirmation != "y":
    print "you thought better, probably a smart move"

print "Checking that we can merge cleanly to master"
# Checkout all the branches required to update & merge forward
promotion_chain = promote.get_promotion_chain(git_directory, target_branch, upstream_name=remote_name)
promote.check_merge_forward(git_directory, promotion_chain)


print "Getting all the branches required, and pulling the latest version"
for git_branch in promotion_chain:
    promote.checkout_branch(git_directory, git_branch, remote_name=remote_name)

# Update the version on source and merge up
print "Bumping the stage on source before merging to target"
promote.checkout_branch(git_directory, source_branch, remote_name=remote_name)
subprocess.check_call(["./update-version.py", "--update-type", "stage", git_directory], cwd=current_directory)

new_version = builder.get_nvr_from_spec_file_in_directory(git_directory)
msg = "bumped version to %s" % new_version
subprocess.check_call(["git", "commit", "-a", "-m", msg], cwd=git_directory)
def get_components(configuration):
    repos = configuration['repositories']
    for component in repos:
        yield component

# Build our working_dir
working_dir = WORKING_DIR
print working_dir
# Load the config file
configuration = load_config(opts.config)

print "Getting git repos"
for component in get_components(configuration):
    print "Cloning from github: %s" % component.get('git_url')
    branch_name = component['git_branch']
    parent_branch = component.get('parent_branch', None)
    command = ['git', 'clone', component.get('git_url'), '--branch', branch_name]
    subprocess.call(command, cwd=working_dir)
    project_dir = os.path.join(working_dir, component['name'])
    git_branch = promote.get_current_git_upstream_branch(project_dir)
    promotion_chain = promote.get_promotion_chain(project_dir, git_branch, parent_branch=parent_branch)
    promote.check_merge_forward(project_dir, promotion_chain)
    update_version = os.path.join(CI_DIR, 'update-version.py')
    # Update the version to the one specified in the config
    command = ['./update-version.py', '--version', component['version'], project_dir]
    subprocess.call(command, cwd=CI_DIR)
    command = ['git', 'commit', '-a', '-m', 'Bumping version to %s' % component['version']]
    subprocess.call(command, cwd=project_dir)
    promote.merge_forward(project_dir, push=push_to_github, parent_branch=parent_branch) 
示例#6
0
def get_components(configuration):
    repos = configuration['repositories']
    for component in repos:
        yield component

# Build our working_dir
working_dir = WORKING_DIR
print working_dir
# Load the config file
configuration = load_config(opts.config)

print "Getting git repos"
for component in get_components(configuration):
    print "Cloning from github: %s" % component.get('git_url')
    branch_name = component['git_branch']
    parent_branch = component.get('parent_branch', None)
    command = ['git', 'clone', component.get('git_url'), '--branch', branch_name]
    subprocess.call(command, cwd=working_dir)
    project_dir = os.path.join(working_dir, component['name'])
    git_branch = promote.get_current_git_upstream_branch(project_dir)
    promotion_chain = promote.get_promotion_chain(project_dir, git_branch, parent_branch=parent_branch)
    promote.check_merge_forward(project_dir, promotion_chain)
    update_version = os.path.join(CI_DIR, 'update-version.py')
    # Update the version to the one specified in the config
    command = ['./update-version.py', '--version', component['version'], project_dir]
    subprocess.call(command, cwd=CI_DIR)
    command = ['git', 'commit', '-a', '-m', 'Bumping version to %s' % component['version']]
    subprocess.call(command, cwd=project_dir)
    promote.merge_forward(project_dir, push=push_to_github, parent_branch=parent_branch) 
示例#7
0
                                        srpm_dir=TITO_DIR, scratch=True)
    builder.wait_for_completion(build_ids)

    if release_build:
        print "Performing koji release build"
        # Clean out the tito dir first
        builder.ensure_dir(TITO_DIR)
        spec_dir_set = set()
        for spec, dist in build_list:
            spec_dir = os.path.dirname(spec)
            if spec_dir not in spec_dir_set:
                spec_dir_set.add(spec_dir)
                # make sure we are clean to merge forward before tagging
                print "validating merge forward for %s" % spec_dir
                git_branch = promote.get_current_git_upstream_branch(spec_dir)
                promotion_chain = promote.get_promotion_chain(spec_dir, git_branch)
                promote.check_merge_forward(spec_dir, promotion_chain)
                # Tito tag the new releases
                command = ['tito', 'tag', '--keep-version', '--no-auto-changelog']
                subprocess.check_call(command, cwd=spec_dir)
            builder.build_srpm_from_spec(spec_dir, TITO_DIR, testing=False, dist=dist)

        build_ids = builder.build_with_koji(build_tag_prefix=koji_prefix,
                                            srpm_dir=TITO_DIR, scratch=False)
        builder.wait_for_completion(build_ids)
        for spec_dir in spec_dir_set:
            # Push the tags
            command = ['git', 'push']
            subprocess.check_call(command, cwd=spec_dir)
            command = ['git', 'push', '--tag']
            subprocess.check_call(command, cwd=spec_dir)