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)
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) promote.merge_forward(git_directory) print "Merging %s into %s " % (source_branch, target_branch) promote.checkout_branch(git_directory, target_branch, remote_name=remote_name) subprocess.check_call(['git', 'merge', source_branch], cwd=opts.project_directory) print "Bumping the patch level on the source branch" # merge the source into the target branch promote.checkout_branch(git_directory, source_branch, remote_name=remote_name) subprocess.check_call(['./update-version.py', '--update-type', 'patch', git_directory], cwd=current_directory) msg = "bumped version to %s" % new_version subprocess.check_call(['git', 'commit', '-a', '-m', msg], cwd=git_directory) promote.merge_forward(git_directory)
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) # Merge merge the commit forward, pushing along the way promote.merge_forward(spec_dir, push=True) print "Downloading rpms" # Download all the files builder.download_builds(MASH_DIR, download_list) builder.download_rpms_from_scratch_tasks(MASH_DIR, build_ids)
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) promote.merge_forward(git_directory) print "Merging %s into %s " % (source_branch, target_branch) promote.checkout_branch(git_directory, target_branch, remote_name=remote_name) subprocess.check_call(["git", "merge", source_branch], cwd=opts.project_directory) print "Bumping the patch level on the source branch" # merge the source into the target branch promote.checkout_branch(git_directory, source_branch, remote_name=remote_name) subprocess.check_call(["./update-version.py", "--update-type", "patch", git_directory], cwd=current_directory) msg = "bumped version to %s" % new_version subprocess.check_call(["git", "commit", "-a", "-m", msg], cwd=git_directory) promote.merge_forward(git_directory) print "Don't forget the following branches need to be pushed to github:"
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)
builder.wait_for_completion(build_ids) for spec_dir in spec_dir_set: project_name = None project_name = project_name_from_spec_dir(spec_dir) # Push the tags if merge_forward[project_name]: command = ['git', 'push'] subprocess.check_call(command, cwd=spec_dir) command = ['git', 'push', '--tag'] subprocess.check_call(command, cwd=spec_dir) if merge_forward[project_name]: # Merge the commit forward, pushing along the way git_branch = promote.get_current_git_upstream_branch(spec_dir) promote.merge_forward(spec_dir, push=True, parent_branch=parent_branches[git_branch]) print "Downloading rpms" # Download all the files builder.download_builds(MASH_DIR, download_list) builder.download_rpms_from_scratch_tasks(MASH_DIR, build_ids) print "Building the repositories" builder.normalize_directories(MASH_DIR) comps_file = os.path.join(working_dir, 'pulp', 'comps.xml') builder.build_repositories(MASH_DIR, comps_file=comps_file) if not opts.disable_push: print "Uploading completed repo" # Rsync the repos to fedorapeople /srv/repos/pulp/pulp/testing/automation/<rsync-target-dir> automation_dir = '/srv/repos/pulp/pulp/testing/automation/'
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) # Merge merge the commit forward, pushing along the way promote.merge_forward(spec_dir, push=True) print "Downloading rpms" # Download all the files builder.download_builds(MASH_DIR, download_list) builder.download_rpms_from_scratch_tasks(MASH_DIR, build_ids) print "Building the repositories" builder.normalize_directories(MASH_DIR) comps_file = os.path.join(working_dir, 'pulp', 'comps.xml') builder.build_repositories(MASH_DIR, comps_file=comps_file) if not opts.disable_push: print "Uploading completed repo" # Rsync the repos to fedorapeople /srv/repos/pulp/pulp/testing/automation/<rsync-target-dir> automation_dir = '/srv/repos/pulp/pulp/testing/automation/'
for spec_dir in spec_dir_set: project_name = None project_name = project_name_from_spec_dir(spec_dir) # Push the tags if merge_forward[project_name]: command = ['git', 'push'] subprocess.check_call(command, cwd=spec_dir) command = ['git', 'push', '--tag'] subprocess.check_call(command, cwd=spec_dir) if merge_forward[project_name]: # Merge the commit forward, pushing along the way git_branch = promote.get_current_git_upstream_branch(spec_dir) promote.merge_forward( spec_dir, push=True, parent_branch=parent_branches[git_branch]) print("Downloading rpms") # Download all the files builder.download_builds(MASH_DIR, download_list) builder.download_rpms_from_scratch_tasks(MASH_DIR, build_ids) print("Building the repositories") builder.normalize_directories(MASH_DIR) comps_file = os.path.join(WORKING_DIR, 'pulp', 'comps.xml') builder.build_repositories(MASH_DIR, comps_file=comps_file) if not opts.disable_push: print("Uploading completed repo") # Rsync the repos to fedorapeople /srv/repos/pulp/pulp/testing/automation/<rsync-target-dir>