From: Zac Medico Date: Fri, 21 Oct 2011 04:07:34 +0000 (-0700) Subject: UpdateChangeLog: split out get_committer_name() X-Git-Tag: v2.2.0_alpha70~7 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0966be903d19dd9999568de3baa3f9815e1e4369;p=portage.git UpdateChangeLog: split out get_committer_name() --- diff --git a/bin/repoman b/bin/repoman index 5b01825b7..bf91b85a9 100755 --- a/bin/repoman +++ b/bin/repoman @@ -2447,6 +2447,7 @@ else: if options.echangelog in ('y', 'force'): logging.info("checking for unmodified ChangeLog files") + committer_name = utilities.get_committer_name(env=repoman_settings) for x in sorted(vcs_files_to_cps( chain(myupdates, mymanifests, myremoved))): catdir, pkgdir = x.split("/") @@ -2468,10 +2469,12 @@ else: clnew = [elem[cdrlen:] for elem in mynew if elem.startswith(checkdir_relative)] clremoved = [elem[cdrlen:] for elem in myremoved if elem.startswith(checkdir_relative)] clchanged = [elem[cdrlen:] for elem in mychanged if elem.startswith(checkdir_relative)] - new_changelog = utilities.UpdateChangeLog(checkdir_relative, \ - catdir, pkgdir, \ - clnew, clremoved, clchanged, \ - changelog_msg, options.pretend, repodir) + new_changelog = utilities.UpdateChangeLog(checkdir_relative, + committer_name, changelog_msg, + os.path.join(repodir, 'skel.ChangeLog'), + catdir, pkgdir, + new=clnew, removed=clremoved, changed=clchanged, + pretend=options.pretend) if new_changelog is None: writemsg_level("!!! Updating the ChangeLog failed\n", \ level=logging.ERROR, noiselevel=-1) diff --git a/pym/repoman/utilities.py b/pym/repoman/utilities.py index c1a9da84a..0ecc92cc7 100644 --- a/pym/repoman/utilities.py +++ b/pym/repoman/utilities.py @@ -16,6 +16,7 @@ __all__ = [ "format_qa_output", "get_commit_message_with_editor", "get_commit_message_with_stdin", + "get_committer_name", "have_profile_dir", "parse_metadata_use", "UnknownHerdsError", @@ -588,30 +589,34 @@ def update_copyright(fn_path, year, pretend): util.apply_stat_permissions(fn_path, fn_stat) fn_hdl.close() -def UpdateChangeLog(pkgdir, category, package, new, removed, changed, \ - msg, pretend, repodir): +def get_committer_name(env=None): + """Generate a committer string like echangelog does.""" + if env is None: + env = os.environ + if 'GENTOO_COMMITTER_NAME' in env and \ + 'GENTOO_COMMITTER_EMAIL' in env: + user = '%s <%s>' % (env['GENTOO_COMMITTER_NAME'], + env['GENTOO_COMMITTER_EMAIL']) + elif 'GENTOO_AUTHOR_NAME' in env and \ + 'GENTOO_AUTHOR_EMAIL' in env: + user = '%s <%s>' % (env['GENTOO_AUTHOR_NAME'], + env['GENTOO_AUTHOR_EMAIL']) + elif 'ECHANGELOG_USER' in env: + user = env['ECHANGELOG_USER'] + else: + pwd_struct = pwd.getpwuid(os.getuid()) + gecos = pwd_struct.pw_gecos.split(',')[0] # bug #80011 + user = '%s <%s@gentoo.org>' % (gecos, pwd_struct.pw_name) + return user + +def UpdateChangeLog(pkgdir, user, msg, skel_path, category, package, + new=(), removed=(), changed=(), pretend=False): """ Write an entry to an existing ChangeLog, or create a new one. Updates copyright year on changed files, and updates the header of ChangeLog with the contents of skel.ChangeLog. """ - # figure out who to write as - if 'GENTOO_COMMITTER_NAME' in os.environ and \ - 'GENTOO_COMMITTER_EMAIL' in os.environ: - user = '%s <%s>' % (os.environ['GENTOO_COMMITTER_NAME'], \ - os.environ['GENTOO_COMMITTER_EMAIL']) - elif 'GENTOO_AUTHOR_NAME' in os.environ and \ - 'GENTOO_AUTHOR_EMAIL' in os.environ: - user = '%s <%s>' % (os.environ['GENTOO_AUTHOR_NAME'], \ - os.environ['GENTOO_AUTHOR_EMAIL']) - elif 'ECHANGELOG_USER' in os.environ: - user = os.environ['ECHANGELOG_USER'] - else: - pwd_struct = pwd.getpwuid(os.getuid()) - gecos = pwd_struct.pw_gecos.split(',')[0] # bug #80011 - user = '%s <%s@gentoo.org>' % (gecos, pwd_struct.pw_name) - if '