public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/repoman/, bin/
Date: Fri, 21 Oct 2011 04:08:48 +0000 (UTC)	[thread overview]
Message-ID: <0966be903d19dd9999568de3baa3f9815e1e4369.zmedico@gentoo> (raw)

commit:     0966be903d19dd9999568de3baa3f9815e1e4369
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 21 04:07:34 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Oct 21 04:07:34 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0966be90

UpdateChangeLog: split out get_committer_name()

---
 bin/repoman              |   11 +++++++----
 pym/repoman/utilities.py |   44 ++++++++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/bin/repoman b/bin/repoman
index 5b01825..bf91b85 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 c1a9da8..0ecc92c 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')



             reply	other threads:[~2011-10-21  4:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-21  4:08 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-02-12  0:53 [gentoo-commits] proj/portage:master commit in: pym/repoman/, bin/ Chris Reffett
2012-05-25 16:18 Mike Frysinger
2011-11-21 17:12 Zac Medico
2011-10-20 20:40 Fabian Groffen
2011-10-17  0:14 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0966be903d19dd9999568de3baa3f9815e1e4369.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox