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

Matt Jordan asteriskteam at digium.com
Wed May 6 13:44:31 CDT 2015


Matt Jordan has uploaded a new change for review.

  https://gerrit.asterisk.org/380

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, 26 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/repotools refs/changes/80/380/1

diff --git a/digium_commits.py b/digium_commits.py
index f4508fa..c06195f 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,31 @@
 
         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
+        '''
+        text = "{0} [{1}]  {2}\n\n".format(
+            datetime.fromtimestamp(self.raw.authored_date).strftime(
+                    '%Y-%m-%d %H:%M +0000'),
+            self.raw.hexsha[:10],
+            ",".join([str(coder) for coder in self.get_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: newchange
Gerrit-Change-Id: I58f59c461aeb765f6ead18104f82e8f982c413ae
Gerrit-PatchSet: 1
Gerrit-Project: repotools
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>



More information about the asterisk-code-review mailing list