summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-10-20 21:07:34 -0700
committerZac Medico <zmedico@gentoo.org>2011-10-20 21:07:34 -0700
commit0966be903d19dd9999568de3baa3f9815e1e4369 (patch)
tree794024f278af81e4e72588bd2a50a664acb61d65
parent44a03c9f2218ae7cfdc03aae495d255e0ca2e5b1 (diff)
downloadportage-0966be903d19dd9999568de3baa3f9815e1e4369.tar.gz
portage-0966be903d19dd9999568de3baa3f9815e1e4369.tar.bz2
portage-0966be903d19dd9999568de3baa3f9815e1e4369.zip
UpdateChangeLog: split out get_committer_name()
-rwxr-xr-xbin/repoman11
-rw-r--r--pym/repoman/utilities.py44
2 files changed, 31 insertions, 24 deletions
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 '<root@' in user:
err = 'Please set ECHANGELOG_USER or run as non-root'
logging.critical(err)
@@ -647,8 +652,7 @@ def UpdateChangeLog(pkgdir, category, package, new, removed, changed, \
# we will only need the ChangeLog skeleton if there is no
# ChangeLog yet
try:
- clskel_path = os.path.join(repodir, 'skel.ChangeLog')
- clskel_file = io.open(_unicode_encode(clskel_path,
+ clskel_file = io.open(_unicode_encode(skel_path,
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['repo.content'],
errors='replace')