def main(args): """gbs submit entry point.""" workdir = args.gitdir orphan_packaging = configmgr.get('packaging_branch', 'orphan-devel') if orphan_packaging and args.commit == 'HEAD': log.error( "You seem to be submitting a development branch of an " "(orphan) packaging branch. Please export your changes to the " "packaging branch with 'gbs devel export' and submit from there.") raise GbsError("Refusing to submit from devel branch") message = args.msg if message is None: message = get_message() if not message: raise GbsError("tag message is required") try: repo = RpmGitRepository(workdir) commit = repo.rev_parse(args.commit) current_branch = repo.get_branch() except GitRepositoryError, err: raise GbsError(str(err))
def main(args): """gbs submit entry point.""" workdir = args.gitdir orphan_packaging = configmgr.get('packaging_branch', 'orphan-devel') if orphan_packaging and args.commit == 'HEAD': log.error("You seem to be submitting a development branch of an " "(orphan) packaging branch. Please export your changes to" "the packaging branch with 'gbs devel export' and submit" "from there.") raise GbsError("Refusing to submit from devel branch") message = args.msg if message is None: message = get_message() if not message: raise GbsError("tag message is required") try: repo = RpmGitRepository(workdir) commit = repo.rev_parse(args.commit) current_branch = repo.get_branch() except GitRepositoryError, err: raise GbsError(str(err))
def main(args): """gbs submit entry point.""" workdir = args.gitdir message = args.msg if message is None: message = get_message() if not message: raise GbsError("tag message is required") try: repo = RpmGitRepository(workdir) commit = repo.rev_parse(args.commit) current_branch = repo.get_branch() except GitRepositoryError, err: raise GbsError(str(err))
def main(argv): """Main function for the gbp pq-rpm command""" retval = 0 (options, args) = parse_args(argv) if not options: return ExitCodes.parse_error gbp.log.setup(options.color, options.verbose, options.color_scheme) if len(args) < 2: gbp.log.err("No action given.") return 1 else: action = args[1] if args[1] in ["export", "import", "rebase", "drop", "switch", "convert"]: pass elif args[1] in ["apply"]: if len(args) != 3: gbp.log.err("No patch name given.") return 1 else: patchfile = args[2] else: gbp.log.err("Unknown action '%s'." % args[1]) return 1 try: repo = RpmGitRepository(os.path.curdir) except GitRepositoryError: gbp.log.err("%s is not a git repository" % (os.path.abspath('.'))) return 1 try: # Create base temporary directory for this run init_tmpdir(options.tmp_dir, prefix='pq-rpm_') current = repo.get_branch() if action == "export": export_patches(repo, options) elif action == "import": import_spec_patches(repo, options) elif action == "drop": drop_pq(repo, current) elif action == "rebase": rebase_pq(repo, options) elif action == "apply": patch = Patch(patchfile) apply_single_patch(repo, current, patch, fallback_author=None) elif action == "switch": switch_pq(repo, current) except KeyboardInterrupt: retval = 1 gbp.log.err("Interrupted. Aborting.") except CommandExecFailed: retval = 1 except GitRepositoryError as err: gbp.log.err("Git command failed: %s" % err) retval = 1 except GbpError as err: if str(err): gbp.log.err(err) retval = 1 finally: del_tmpdir() return retval
def main(argv): ret = 0 (options, args) = parse_args(argv) if not options: return 1 tmpdir = tempfile.mkdtemp(dir=options.tmp_dir, prefix='import-orig-rpm_') try: try: repo = RpmGitRepository('.') except GitRepositoryError: raise GbpError, "%s is not a git repository" % ( os.path.abspath('.')) spec = find_spec(repo, options) source = find_source(spec, options, args) # an empty repo has now branches: initial_branch = repo.get_branch() is_empty = False if initial_branch else True if not repo.has_branch(options.upstream_branch): if options.create_missing_branches: gbp.log.info("Will create missing branch '%s'" % options.upstream_branch) elif is_empty: options.create_missing_branches = True else: raise GbpError(no_upstream_branch_msg % options.upstream_branch) sourcepackage, version = detect_name_and_version( repo, source, spec, options) (clean, out) = repo.is_clean() if not clean and not is_empty: gbp.log.err( "Repository has uncommitted changes, commit these first: ") raise GbpError, out if repo.bare: set_bare_repo_options(options) # Prepare sources for importing if options.pristine_tar: prepare_pristine = pristine_tarball_name( source, sourcepackage, version, options.pristine_tarball_name) else: prepare_pristine = None unpacked_orig, pristine_orig = \ prepare_sources(source, sourcepackage, version, prepare_pristine, options.filters, options.filter_pristine_tar, options.orig_prefix, tmpdir) # Don't mess up our repo with git metadata from an upstream tarball if os.path.isdir(os.path.join(unpacked_orig, '.git/')): raise GbpError("The orig tarball contains .git metadata - " "giving up.") try: filter_msg = ["", " (filtering out %s)" % options.filters ][len(options.filters) > 0] gbp.log.info("Importing '%s' to branch '%s'%s..." % (source.path, options.upstream_branch, filter_msg)) gbp.log.info("Source package is %s" % sourcepackage) gbp.log.info("Upstream version is %s" % version) msg = upstream_import_commit_msg(options, version) if options.vcs_tag: parents = [repo.rev_parse("%s^{}" % options.vcs_tag)] else: parents = None commit = repo.commit_dir( unpacked_orig, msg=msg, branch=options.upstream_branch, other_parents=parents, create_missing_branch=options.create_missing_branches) if options.pristine_tar and pristine_orig: gbp.log.info("Pristine-tar: commiting %s" % pristine_orig) repo.pristine_tar.commit(pristine_orig, options.upstream_branch) tag_str_fields = dict(upstreamversion=version, vendor="Upstream") tag = repo.version_to_tag(options.upstream_tag, tag_str_fields) repo.create_tag(name=tag, msg="Upstream version %s" % version, commit=commit, sign=options.sign_tags, keyid=options.keyid) if options.merge: gbp.log.info("Merging to '%s'" % options.packaging_branch) if repo.has_branch(options.packaging_branch): repo.set_branch(options.packaging_branch) try: repo.merge(tag) except GitRepositoryError: raise GbpError, """Merge failed, please resolve.""" else: repo.create_branch(options.packaging_branch, rev=options.upstream_branch) if repo.get_branch() == options.packaging_branch: repo.force_head(options.packaging_branch, hard=True) if options.postimport: info = {'upstreamversion': version} env = {'GBP_BRANCH': options.packaging_branch} gbpc.Command(options.postimport % info, extra_env=env, shell=True)() # Update working copy and index if we've possibly updated the # checked out branch current_branch = repo.get_branch() if (current_branch == options.upstream_branch or current_branch == repo.pristine_tar_branch): repo.force_head(current_branch, hard=True) except (GitRepositoryError, gbpc.CommandExecFailed): raise GbpError, "Import of %s failed" % source.path except GbpError, err: if len(err.__str__()): gbp.log.err(err) ret = 1
def main(argv): """Main function for the gbp pq-rpm command""" retval = 0 (options, args) = parse_args(argv) if not options: return 1 gbp.log.setup(options.color, options.verbose, options.color_scheme) if len(args) < 2: gbp.log.err("No action given.") return 1 else: action = args[1] if args[1] in ["export", "import", "rebase", "drop", "switch", "convert"]: pass elif args[1] in ["apply"]: if len(args) != 3: gbp.log.err("No patch name given.") return 1 else: patchfile = args[2] else: gbp.log.err("Unknown action '%s'." % args[1]) return 1 try: repo = RpmGitRepository(os.path.curdir) except GitRepositoryError: gbp.log.err("%s is not a git repository" % (os.path.abspath('.'))) return 1 try: # Create base temporary directory for this run options.tmp_dir = tempfile.mkdtemp(dir=options.tmp_dir, prefix='gbp-pq-rpm_') current = repo.get_branch() if action == "export": export_patches(repo, options) elif action == "import": import_spec_patches(repo, options) elif action == "drop": drop_pq(repo, current) elif action == "rebase": rebase_pq(repo, options) elif action == "apply": patch = Patch(patchfile) apply_single_patch(repo, current, patch, fallback_author=None) elif action == "switch": switch_pq(repo, current) except CommandExecFailed: retval = 1 except GitRepositoryError as err: gbp.log.err("Git command failed: %s" % err) retval = 1 except GbpError, err: if str(err): gbp.log.err(err) retval = 1