[asterisk-commits] digium commits: Add a function that returns a change log entry (repotools[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 8 15:56:08 CDT 2015


Matt Jordan has submitted this change and it was merged.

Change subject: digium_commits: Add a function that returns a change log entry
......................................................................


digium_commits: Add a function that returns a change log entry

This patch adds a new function to the commit message parser, which
formats a commit message into a format suitable for a change log. This
includes a particular metadata line, as well as indending the commit
message to relatively match the historical Asterisk change logs.

REP-15

Change-Id: I58f59c461aeb765f6ead18104f82e8f982c413ae
---
M digium_commits.py
1 file changed, 31 insertions(+), 0 deletions(-)

Approvals:
  Samuel Galarneau: Looks good to me, but someone else must approve
  Matt Jordan: Looks good to me, approved; Verified



diff --git a/digium_commits.py b/digium_commits.py
index f4508fa..522731f 100644
--- a/digium_commits.py
+++ b/digium_commits.py
@@ -7,6 +7,7 @@
 '''
 
 import re
+from datetime import datetime
 
 from digium_jira_user import AsteriskUser
 
@@ -194,6 +195,36 @@
 
         return "(No Summary Available)"
 
+    def get_change_log(self):
+        '''Get a change log compatible version of the message
+
+        This function returns a string which is a ChangeLog compatible version
+        of the commit message. This requires that the raw commit message be
+        available for metadata.
+
+        Returns:
+        A change log string
+        '''
+
+        # Create the log message header
+        timestamp = datetime.fromtimestamp(
+            self.raw.authored_date).strftime('%Y-%m-%d %H:%M +0000')
+        coders = ','.join([str(coder) for coder in self.get_coders()])
+        text = "{0} [{1}]  {2}\n\n".format(timestamp,
+                                           self.raw.hexsha[:10],
+                                           coders)
+
+        for i, line in enumerate(self.message.split('\n')):
+            if i == 0:
+                text += '\t* {0}\n'.format(line)
+            elif len(line) != 0:
+                text += '\t  {0}\n'.format(line)
+            else:
+                text += '\n'
+
+        return text
+
+
     def __repr__(self):
         '''Return a string represenation of the object'''
         return 'Author: {0}\n{1}'.format(self.author, self.message)

-- 
To view, visit https://gerrit.asterisk.org/380
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I58f59c461aeb765f6ead18104f82e8f982c413ae
Gerrit-PatchSet: 3
Gerrit-Project: repotools
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Samuel Galarneau <sgalarneau at digium.com>



More information about the asterisk-commits mailing list