def debian_branch_merge(repo, tag, version, options): try: func = globals()["debian_branch_merge_by_%s" % options.merge_mode] except KeyError: raise GbpError("%s is not a valid merge mode" % options.merge_mode) func(repo, tag, version, options) if options.postimport: epoch = '' if os.access('debian/changelog', os.R_OK): # No need to check the changelog file from the # repository, since we're certain that we're on # the debian-branch cp = ChangeLog(filename='debian/changelog') if cp.has_epoch(): epoch = '%s:' % cp.epoch debian_version = "%s%s-1" % (epoch, version) info = {'version': debian_version} env = { 'GBP_BRANCH': options.debian_branch, 'GBP_TAG': tag, 'GBP_UPSTREAM_VERSION': version, 'GBP_DEBIAN_VERSION': debian_version, } Hook('Postimport', format_str(options.postimport, info), extra_env=env)()
def postunpack_hook(repo, tmp_dir, sources, options): if options.postunpack: Hook('Postunpack', options.postunpack, extra_env={'GBP_GIT_DIR': repo.git_dir, 'GBP_TMP_DIR': tmp_dir, 'GBP_SOURCES_DIR': sources[0].unpacked} )(dir=tmp_dir)
def postunpack_hook(repo, tmp_dir, options): if options.postunpack: Hook('Postunpack', options.postunpack, extra_env={ 'GBP_GIT_DIR': repo.git_dir, 'GBP_TMP_DIR': tmp_dir })(dir=tmp_dir)
def perform_tagging(repo, source, options, hook_env=None): """ Perform the tagging Select brach to tag, create tag and run hooks """ branch = repo.branch if branch and is_pq_branch(branch): commit = repo.get_merge_base(branch, pq_branch_base(branch)) else: commit = repo.head tag = create_debian_tag(repo, source, commit, options) if options.posttag: sha = repo.rev_parse("%s^{}" % tag) Hook('Posttag', options.posttag, extra_env=Hook.md(hook_env or {}, { 'GBP_TAG': tag, 'GBP_BRANCH': branch or '(no branch)', 'GBP_SHA1': sha }))()
def postimport_hook(repo, tag, version, options): if options.postimport: epoch = '' if os.access('debian/changelog', os.R_OK): # No need to check the changelog file from the # repository, since we're certain that we're on # the debian-branch cp = ChangeLog(filename='debian/changelog') if cp.has_epoch(): epoch = '%s:' % cp.epoch debian_version = "%s%s-1" % (epoch, version) info = {'version': debian_version} env = { 'GBP_BRANCH': options.debian_branch, 'GBP_TAG': tag, 'GBP_UPSTREAM_VERSION': version, 'GBP_DEBIAN_VERSION': debian_version, } Hook('Postimport', format_str(options.postimport, info), extra_env=env)()
def perform_tagging(repo, source, options, hook_env=None): """ Perform the tagging Select brach to tag, create tag and run hooks """ branch = repo.branch if branch and is_pq_branch(branch): commit = repo.get_merge_base(branch, pq_branch_base(branch)) else: commit = repo.head tag = create_debian_tag(repo, source, commit, options) if options.posttag: sha = repo.rev_parse("%s^{}" % tag) Hook('Posttag', options.posttag, extra_env=Hook.md(hook_env or {}, {'GBP_TAG': tag, 'GBP_BRANCH': branch or '(no branch)', 'GBP_SHA1': sha}) )()
def main(argv): retval = 0 prefix = "git-" source = None branch = None hook_env = {} options, gbp_args, dpkg_args = parse_args(argv, prefix) if not options: return ExitCodes.parse_error try: repo = DebianGitRepository(os.path.curdir) except GitRepositoryError: gbp.log.err("%s is not a git repository" % (os.path.abspath('.'))) return 1 try: clean_working_tree(options, repo) try: branch = repo.get_branch() except GitRepositoryError: # Not being on any branch is o.k. with --git-ignore-branch if not options.ignore_branch: raise if not options.ignore_new and not options.ignore_branch: if branch != options.debian_branch: gbp.log.err("You are not on branch '%s' but on '%s'" % (options.debian_branch, branch)) raise GbpError( "Use --git-ignore-branch to ignore or --git-debian-branch to set the branch name." ) head = repo.head tree = write_tree(repo, options) source = source_vfs(repo, options, tree) check_tag(options, repo, source) if not options.tag_only: output_dir = prepare_output_dir(options.export_dir) tarball_dir = options.tarball_dir or output_dir # Get/build the upstream tarball if necessary. We delay this in # case of a postexport hook so the hook gets a chance to modify the # sources and create different tarballs (#640382) # We don't delay it in general since we want to fail early if the # tarball is missing. if not source.is_native(): if options.postexport: gbp.log.info( "Postexport hook set, delaying tarball creation") else: prepare_upstream_tarball(repo, source, options, tarball_dir, output_dir) build_env, hook_env = setup_pbuilder(options, repo, source.is_native()) # Export to another build dir if requested: if options.export_dir: tmp_dir = os.path.join(output_dir, "%s-tmp" % source.sourcepkg) export_source(repo, tree, source, options, tmp_dir, output_dir) # Run postexport hook if options.postexport: Hook('Postexport', options.postexport, extra_env=Hook.md(hook_env, { 'GBP_GIT_DIR': repo.git_dir, 'GBP_TMP_DIR': tmp_dir }))(dir=tmp_dir) major = (source.debian_version if source.is_native() else source.upstream_version) export_dir = os.path.join(output_dir, "%s-%s" % (source.sourcepkg, major)) gbp.log.info("Moving '%s' to '%s'" % (tmp_dir, export_dir)) move_old_export(export_dir) os.rename(tmp_dir, export_dir) # Delayed tarball creation in case a postexport hook is used: if not source.is_native() and options.postexport: prepare_upstream_tarball(repo, source, options, tarball_dir, output_dir) build_dir = export_dir else: build_dir = repo.path if options.prebuild: Hook('Prebuild', options.prebuild, extra_env=Hook.md(hook_env, { 'GBP_GIT_DIR': repo.git_dir, 'GBP_BUILD_DIR': build_dir }))(dir=build_dir) # Finally build the package: RunAtCommand( options.builder, [pipes.quote(arg) for arg in dpkg_args], shell=True, extra_env=Hook.md(build_env, {'GBP_BUILD_DIR': build_dir}))(dir=build_dir) if options.postbuild: changes = os.path.abspath( "%s/../%s_%s_%s.changes" % (build_dir, source.changelog.name, source.changelog.noepoch, changes_file_suffix(dpkg_args))) gbp.log.debug("Looking for changes file %s" % changes) Hook('Postbuild', options.postbuild, extra_env=Hook.md(hook_env, { 'GBP_CHANGES_FILE': changes, 'GBP_BUILD_DIR': build_dir }))() if options.tag or options.tag_only: if is_pq_branch(branch): commit = repo.get_merge_base(branch, pq_branch_base(branch)) else: commit = head tag = repo.version_to_tag(options.debian_tag, source.version) gbp.log.info("Tagging %s as %s" % (source.version, tag)) if options.retag and repo.has_tag(tag): repo.delete_tag(tag) tag_msg = format_str( options.debian_tag_msg, dict(pkg=source.sourcepkg, version=source.version)) repo.create_tag(name=tag, msg=tag_msg, sign=options.sign_tags, commit=commit, keyid=options.keyid) if options.posttag: sha = repo.rev_parse("%s^{}" % tag) Hook('Posttag', options.posttag, extra_env=Hook.md( hook_env, { 'GBP_TAG': tag, 'GBP_BRANCH': branch or '(no branch)', 'GBP_SHA1': sha }))() except KeyboardInterrupt: retval = 1 gbp.log.err("Interrupted. Aborting.") except CommandExecFailed: retval = 1 except (GbpError, GitRepositoryError) as err: if str(err): gbp.log.err(err) retval = 1 except DebianSourceError as err: gbp.log.err(err) source = None retval = 1 finally: drop_index(repo) if not options.tag_only: if options.export_dir and options.purge and not retval: RemoveTree(export_dir)() if source: summary, msg = gbp.notifications.build_msg(source.changelog, not retval) if not gbp.notifications.notify(summary, msg, options.notify): gbp.log.err("Failed to send notification") retval = 1 return retval
def main(argv): retval = 0 prefix = "git-" source = None branch = None hook_env = {} options, gbp_args, dpkg_args = parse_args(argv, prefix) if not options: return ExitCodes.parse_error try: repo = DebianGitRepository(os.path.curdir) except GitRepositoryError: gbp.log.err("%s is not a git repository" % (os.path.abspath('.'))) return 1 try: Command(options.cleaner, shell=True)() if not options.ignore_new: (ret, out) = repo.is_clean() if not ret: gbp.log.err("You have uncommitted changes in your source tree:") gbp.log.err(out) raise GbpError("Use --git-ignore-new to ignore.") try: branch = repo.get_branch() except GitRepositoryError: # Not being on any branch is o.k. with --git-ignore-branch if not options.ignore_branch: raise if not options.ignore_new and not options.ignore_branch: if branch != options.debian_branch: gbp.log.err("You are not on branch '%s' but on '%s'" % (options.debian_branch, branch)) raise GbpError("Use --git-ignore-branch to ignore or --git-debian-branch to set the branch name.") head = repo.head tree = write_tree(repo, options) source = source_vfs(repo, options, tree) check_tag(options, repo, source) if not options.tag_only: output_dir = prepare_output_dir(options.export_dir) tarball_dir = options.tarball_dir or output_dir # Get/build the upstream tarball if necessary. We delay this in # case of a postexport hook so the hook gets a chance to modify the # sources and create different tarballs (#640382) # We don't delay it in general since we want to fail early if the # tarball is missing. if not source.is_native(): if options.postexport: gbp.log.info("Postexport hook set, delaying tarball creation") else: prepare_upstream_tarball(repo, source.changelog, options, tarball_dir, output_dir) build_env, hook_env = setup_pbuilder(options, repo, source.is_native()) # Export to another build dir if requested: if options.export_dir: tmp_dir = os.path.join(output_dir, "%s-tmp" % source.sourcepkg) export_source(repo, tree, source, options, tmp_dir, output_dir) # Run postexport hook if options.postexport: Hook('Postexport', options.postexport, extra_env=Hook.md(hook_env, {'GBP_GIT_DIR': repo.git_dir, 'GBP_TMP_DIR': tmp_dir}) )(dir=tmp_dir) major = (source.changelog.debian_version if source.is_native() else source.changelog.upstream_version) export_dir = os.path.join(output_dir, "%s-%s" % (source.sourcepkg, major)) gbp.log.info("Moving '%s' to '%s'" % (tmp_dir, export_dir)) move_old_export(export_dir) os.rename(tmp_dir, export_dir) # Delayed tarball creation in case a postexport hook is used: if not source.is_native() and options.postexport: prepare_upstream_tarball(repo, source.changelog, options, tarball_dir, output_dir) build_dir = export_dir else: build_dir = repo.path if options.prebuild: Hook('Prebuild', options.prebuild, extra_env=Hook.md(hook_env, {'GBP_GIT_DIR': repo.git_dir, 'GBP_BUILD_DIR': build_dir}) )(dir=build_dir) # Finally build the package: RunAtCommand(options.builder, [pipes.quote(arg) for arg in dpkg_args], shell=True, extra_env=Hook.md(build_env, {'GBP_BUILD_DIR': build_dir}) )(dir=build_dir) if options.postbuild: changes = os.path.abspath("%s/../%s_%s_%s.changes" % (build_dir, source.sourcepkg, source.changelog.noepoch, changes_file_suffix(dpkg_args))) gbp.log.debug("Looking for changes file %s" % changes) Hook('Postbuild', options.postbuild, extra_env=Hook.md(hook_env, {'GBP_CHANGES_FILE': changes, 'GBP_BUILD_DIR': build_dir}) )() if options.tag or options.tag_only: tag = repo.version_to_tag(options.debian_tag, source.changelog.version) gbp.log.info("Tagging %s as %s" % (source.changelog.version, tag)) if options.retag and repo.has_tag(tag): repo.delete_tag(tag) tag_msg = format_str(options.debian_tag_msg, dict(pkg=source.sourcepkg, version=source.changelog.version)) repo.create_tag(name=tag, msg=tag_msg, sign=options.sign_tags, commit=head, keyid=options.keyid) if options.posttag: sha = repo.rev_parse("%s^{}" % tag) Hook('Posttag', options.posttag, extra_env=Hook.md(hook_env, {'GBP_TAG': tag, 'GBP_BRANCH': branch or '(no branch)', 'GBP_SHA1': sha}) )() except KeyboardInterrupt: retval = 1 gbp.log.err("Interrupted. Aborting.") except CommandExecFailed: retval = 1 except (GbpError, GitRepositoryError) as err: if str(err): gbp.log.err(err) retval = 1 except DebianSourceError as err: gbp.log.err(err) source = None retval = 1 finally: drop_index() if not options.tag_only: if options.export_dir and options.purge and not retval: RemoveTree(export_dir)() if source: summary, msg = gbp.notifications.build_msg(source.changelog, not retval) if not gbp.notifications.notify(summary, msg, options.notify): gbp.log.err("Failed to send notification") retval = 1 return retval
def main(argv): retval = 0 prefix = "git-" source = None hook_env = {} options, gbp_args, dpkg_args = parse_args(argv, prefix) if not options: return ExitCodes.parse_error try: repo = DebianGitRepository(os.path.curdir) except GitRepositoryError: gbp.log.err("%s is not a git repository" % (os.path.abspath('.'))) return 1 try: clean_working_tree(options, repo) check_branch(repo, options) tree = maybe_write_tree(repo, options) source = source_vfs(repo, options, tree) check_tag(options, repo, source) if not options.tag_only: output_dir = prepare_output_dir(options.export_dir) tarball_dir = options.tarball_dir or output_dir tmp_dir = os.path.join(output_dir, "%s-tmp" % source.sourcepkg) build_env, hook_env = setup_pbuilder(options, repo, source.is_native()) major = (source.debian_version if source.is_native() else source.upstream_version) export_dir = os.path.join(output_dir, "%s-%s" % (source.sourcepkg, major)) build_dir = export_dir if options.export_dir else repo.path changes_file = changes_file_name(source, build_dir, dpkg_args) # Get/build the upstream tarball if necessary. We delay this in # case of a postexport hook so the hook gets a chance to modify the # sources and create different tarballs (#640382) # We don't delay it in general since we want to fail early if the # tarball is missing. if not source.is_native(): if options.postexport: gbp.log.info( "Postexport hook set, delaying tarball creation") else: prepare_upstream_tarballs(repo, source, options, tarball_dir, output_dir) # Export to another build dir if requested: if options.export_dir: export_source(repo, tree, source, options, tmp_dir, tarball_dir) # Run postexport hook if options.postexport: Hook('Postexport', options.postexport, extra_env=Hook.md(hook_env, { 'GBP_GIT_DIR': repo.git_dir, 'GBP_TMP_DIR': tmp_dir }))(dir=tmp_dir) gbp.log.info("Moving '%s' to '%s'" % (tmp_dir, export_dir)) move_old_export(export_dir) os.rename(tmp_dir, export_dir) # Delayed tarball creation in case a postexport hook is used: if not source.is_native() and options.postexport: prepare_upstream_tarballs(repo, source, options, tarball_dir, output_dir) if options.prebuild: Hook('Prebuild', options.prebuild, extra_env=Hook.md(hook_env, { 'GBP_GIT_DIR': repo.git_dir, 'GBP_BUILD_DIR': build_dir }))(dir=build_dir) # Finally build the package: RunAtCommand( options.builder, [pipes.quote(arg) for arg in dpkg_args], shell=True, extra_env=Hook.md(build_env, {'GBP_BUILD_DIR': build_dir}))(dir=build_dir) if options.postbuild: gbp.log.debug("Looking for changes file %s" % changes_file) Hook('Postbuild', options.postbuild, extra_env=Hook.md( hook_env, { 'GBP_CHANGES_FILE': changes_file, 'GBP_BUILD_DIR': build_dir }))() if options.tag or options.tag_only: perform_tagging(repo, source, options, hook_env) except KeyboardInterrupt: retval = 1 gbp.log.err("Interrupted. Aborting.") except CommandExecFailed: retval = 1 except (GbpError, GitRepositoryError) as err: if str(err): gbp.log.err(err) retval = 1 except DebianSourceError as err: gbp.log.err(err) source = None retval = 1 finally: drop_index(repo) if not options.tag_only: if options.export_dir and options.purge and not retval: RemoveTree(export_dir)() if source: summary, msg = gbp.notifications.build_msg(source.changelog, not retval) if not gbp.notifications.notify(summary, msg, options.notify): gbp.log.err("Failed to send notification") retval = 1 return retval
def main(argv): retval = 0 prefix = "git-" source = None hook_env = {} options, gbp_args, dpkg_args = parse_args(argv, prefix) if not options: return ExitCodes.parse_error try: repo = DebianGitRepository(os.path.curdir) except GitRepositoryError: gbp.log.err("%s is not a git repository" % (os.path.abspath('.'))) return 1 try: clean_working_tree(options, repo) check_branch(repo, options) tree = maybe_write_tree(repo, options) source = source_vfs(repo, options, tree) check_tag(options, repo, source) if not options.tag_only: output_dir = prepare_output_dir(options.export_dir) tarball_dir = output_dir if options.tarball_dir and source.upstream_version is not None: tarball_dir = PkgPolicy.version_subst(options.tarball_dir, source.upstream_version) tmp_dir = os.path.join(output_dir, "%s-tmp" % source.sourcepkg) build_env, hook_env = setup_pbuilder(options, repo, source.is_native()) major = (source.debian_version if source.is_native() else source.upstream_version) export_dir = os.path.join(output_dir, "%s-%s" % (source.sourcepkg, major)) build_dir = export_dir if options.export_dir else repo.path changes_file = changes_file_name(source, build_dir, options.builder, dpkg_args) # Run preexport hook if options.export_dir and options.preexport: Hook('Preexport', options.preexport, extra_env=Hook.md(hook_env, {'GBP_GIT_DIR': repo.git_dir, 'GBP_BUILD_DIR': build_dir}) )() # Get/build the upstream tarball if necessary. We delay this in # case of a postexport hook so the hook gets a chance to modify the # sources and create different tarballs (#640382) # We don't delay it in general since we want to fail early if the # tarball is missing. if not source.is_native(): if options.postexport: gbp.log.info("Postexport hook set, delaying tarball creation") else: prepare_upstream_tarballs(repo, source, options, tarball_dir, output_dir) # Export to another build dir if requested: if options.export_dir: export_source(repo, tree, source, options, tmp_dir, tarball_dir) # Run postexport hook if options.postexport: Hook('Postexport', options.postexport, extra_env=Hook.md(hook_env, {'GBP_GIT_DIR': repo.git_dir, 'GBP_TMP_DIR': tmp_dir}) )(dir=tmp_dir) gbp.log.info("Moving '%s' to '%s'" % (tmp_dir, export_dir)) move_old_export(export_dir) os.rename(tmp_dir, export_dir) # Delayed tarball creation in case a postexport hook is used: if not source.is_native() and options.postexport: prepare_upstream_tarballs(repo, source, options, tarball_dir, output_dir) if options.prebuild: Hook('Prebuild', options.prebuild, extra_env=Hook.md(hook_env, {'GBP_GIT_DIR': repo.git_dir, 'GBP_BUILD_DIR': build_dir}) )(dir=build_dir) # Finally build the package: gbp.log.info("Performing the build") RunAtCommand(options.builder, [pipes.quote(arg) for arg in dpkg_args], shell=True, extra_env=Hook.md(build_env, {'GBP_BUILD_DIR': build_dir}) )(dir=build_dir) if options.postbuild: gbp.log.debug("Looking for changes file %s" % changes_file) Hook('Postbuild', options.postbuild, extra_env=Hook.md(hook_env, {'GBP_CHANGES_FILE': changes_file, 'GBP_BUILD_DIR': build_dir}) )() if options.tag or options.tag_only: perform_tagging(repo, source, options, hook_env) except KeyboardInterrupt: retval = 1 gbp.log.err("Interrupted. Aborting.") except CommandExecFailed: retval = 1 except (GbpError, GitRepositoryError) as err: if str(err): gbp.log.err(err) retval = 1 except DebianSourceError as err: gbp.log.err(err) source = None retval = 1 finally: drop_index(repo) if not options.tag_only: if options.export_dir and options.purge and not retval: RemoveTree(export_dir)() if source: summary, msg = gbp.notifications.build_msg(source.changelog, not retval) if not gbp.notifications.notify(summary, msg, options.notify): gbp.log.err("Failed to send notification") retval = 1 return retval
def main(argv): retval = 0 (options, args) = parse_args(argv) if not options: return ExitCodes.parse_error if len(args) < 2: gbp.log.err("Need a repository to clone.") return 1 else: source = args[1] clone_to, auto_name = (os.path.curdir, True) if len(args) < 3 else (args[2], False) try: GitRepository(clone_to) gbp.log.err("Can't run inside a git repository.") return 1 except GitRepositoryError: pass try: gbp.log.info( "Cloning from '%s'%s" % (source, " into '%s'" % clone_to if not auto_name else '')) repo = DebianGitRepository.clone(clone_to, source, options.depth, auto_name=auto_name, reference=options.reference) os.chdir(repo.path) # Reparse the config files of the cloned repository so we pick up the # branch information from there but don't overwrite hooks: postclone = options.postclone (options, args) = parse_args(argv) # Track all branches: if options.all: remotes = repo.get_remote_branches() for remote in remotes: local = remote.replace("origin/", "", 1) if (not repo.has_branch(local) and local != "HEAD"): repo.create_branch(local, remote) else: # only track gbp's default branches branches = [options.debian_branch, options.upstream_branch] if options.pristine_tar: branches += [repo.pristine_tar_branch] gbp.log.debug('Will track branches: %s' % branches) for branch in branches: remote = 'origin/%s' % branch if (repo.has_branch(remote, remote=True) and not repo.has_branch(branch)): repo.create_branch(branch, remote) repo.set_branch(options.debian_branch) repo_setup.set_user_name_and_email(options.repo_user, options.repo_email, repo) if postclone: Hook( 'Postclone', options.postclone, extra_env={'GBP_GIT_DIR': repo.git_dir}, )() except KeyboardInterrupt: retval = 1 gbp.log.err("Interrupted. Aborting.") 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 return retval
def main(argv): ret = 0 changelog = 'debian/changelog' until = 'HEAD' found_snapshot_banner = False version_change = {} branch = None options, args, dch_options, editor_cmd = parse_args(argv) if not options: return ExitCodes.parse_error try: old_cwd = os.path.abspath(os.path.curdir) try: repo = DebianGitRepository('.', toplevel=False) os.chdir(repo.path) except GitRepositoryError: raise GbpError("%s is not a git repository" % (os.path.abspath('.'))) get_customizations(options.customization_file) try: branch = repo.get_branch() except GitRepositoryError: # Not being on any branch is o.k. with --ignore-branch if not options.ignore_branch: raise if options.debian_branch != branch and not options.ignore_branch: gbp.log.err("You are not on branch '%s' but on '%s'" % (options.debian_branch, branch)) raise GbpError("Use --ignore-branch to ignore or --debian-branch to set the branch name.") source = DebianSource('.') cp = maybe_create_changelog(repo, source, options) if options.since: since = options.since else: since = guess_documented_commit(cp, repo, options.debian_tag) if since: msg = "Continuing from commit '%s'" % since else: msg = "Starting from first commit" gbp.log.info(msg) found_snapshot_banner = has_snapshot_banner(cp) if args: gbp.log.info("Only looking for changes on '%s'" % " ".join(args)) commits = repo.get_commits(since=since, until=until, paths=args, options=options.git_log.split(" ")) commits.reverse() add_section = False # add a new changelog section if: if (options.new_version or options.bpo or options.nmu or options.qa or options.team or options.security): if options.bpo: version_change['increment'] = '--bpo' elif options.nmu: version_change['increment'] = '--nmu' elif options.qa: version_change['increment'] = '--qa' elif options.team: version_change['increment'] = '--team' elif options.security: version_change['increment'] = '--security' else: version_change['version'] = options.new_version # the user wants to force a new version add_section = True elif cp['Distribution'] != "UNRELEASED" and not found_snapshot_banner: if commits: # the last version was a release and we have pending commits add_section = True if options.snapshot: # the user want to switch to snapshot mode add_section = True if add_section and not version_change and not source.is_native(): # Get version from upstream if none provided v = guess_version_from_upstream(repo, options.upstream_tag, options.upstream_branch, cp) if v: version_change['version'] = v i = 0 for c in commits: i += 1 parsed = parse_commit(repo, c, options, last_commit=(i == len(commits))) commit_msg, (commit_author, commit_email) = parsed if not commit_msg: # Some commits can be ignored continue if add_section: # Add a section containing just this message (we can't # add an empty section with dch) cp.add_section(distribution="UNRELEASED", msg=commit_msg, version=version_change, author=commit_author, email=commit_email, dch_options=dch_options) # Adding a section only needs to happen once. add_section = False else: cp.add_entry(commit_msg, commit_author, commit_email, dch_options) # Show a message if there were no commits (not even ignored # commits). if not commits: gbp.log.info("No changes detected from %s to %s." % (since, until)) if add_section: # If we end up here, then there were no commits to include, # so we put a dummy message in the new section. cp.add_section(distribution="UNRELEASED", msg=["UNRELEASED"], version=version_change, dch_options=dch_options) fixup_section(repo, use_git_author=options.use_git_author, options=options, dch_options=dch_options) if options.release: do_release(changelog, repo, cp, use_git_author=options.use_git_author, dch_options=dch_options) elif options.snapshot: (snap, commit, version) = do_snapshot(changelog, repo, options.snapshot_number) gbp.log.info("Changelog %s (snapshot #%d) prepared up to %s" % (version, snap, commit[:7])) if editor_cmd: gbpc.Command(editor_cmd, ["debian/changelog"])() if options.postedit: cp = ChangeLog(filename=changelog) Hook('Postimport', options.postedit, extra_env={'GBP_DEBIAN_VERSION': cp.version})() if options.commit: # Get the version from the changelog file (since dch might # have incremented it, there's no way we can already know # the version). version = ChangeLog(filename=changelog).version # Commit the changes to the changelog file msg = changelog_commit_msg(options, version) repo.commit_files([changelog], msg) gbp.log.info("Changelog committed for version %s" % version) except KeyboardInterrupt: ret = 1 gbp.log.err("Interrupted. Aborting.") except (gbpc.CommandExecFailed, GbpError, GitRepositoryError, DebianSourceError, NoChangeLogError) as err: if str(err): gbp.log.err(err) ret = 1 maybe_debug_raise() finally: os.chdir(old_cwd) return ret