#! /usr/bin/env python
__version__ = '1.5.0'
# Copyright (c) 2015-2016 Matthieu Moy and others
# Copyright (c) 2012-2014 Michael Haggerty and others
# Derived from contrib/hooks/post-receive-email, which is
# Copyright (c) 2007 Andy Parkins
# and also includes contributions by other authors.
#
# This file is part of git-multimail.
#
# git-multimail is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License version
# 2 as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see
#
tag when using HTML format. Escape special HTML characters and addandtags around the given lines if we should be generating HTML as indicated by self._contains_html_diff being set to true. """ if self._contains_html_diff: yield "\n" for line in lines: yield html_escape(line) yield '\n' else: for line in lines: yield line def generate_email(self, push, body_filter=None, extra_header_values={}): """Generate an email describing this change. Iterate over the lines (including the header lines) of an email describing this change. If body_filter is not None, then use it to filter the lines that are intended for the email body. The extra_header_values field is received as a dict and not as **kwargs, to allow passing other keyword arguments in the future (e.g. passing extra values to generate_email_intro()""" for line in self.generate_email_header(**extra_header_values): yield line yield '\n' html_escape_val = (self.environment.html_in_intro and self._contains_html_diff) intro = self.generate_email_intro(html_escape_val) if not self.environment.html_in_intro: intro = self._wrap_for_html(intro) for line in intro: yield line if self.environment.commitBrowseURL: for line in self.generate_browse_link(self.environment.commitBrowseURL): yield line body = self.generate_email_body(push) if body_filter is not None: body = body_filter(body) diff_started = False if self._contains_html_diff: # "white-space: pre" is the default, but we need to # specify it again in case the message is viewed in a # webmail which wraps it in an element setting white-space # to something else (Zimbra does this and sets # white-space: pre-line). yield '' for line in body: if self._contains_html_diff: # This is very, very naive. It would be much better to really # parse the diff, i.e. look at how many lines do we have in # the hunk headers instead of blindly highlighting everything # that looks like it might be part of a diff. bgcolor = '' fgcolor = '' if line.startswith('--- a/'): diff_started = True bgcolor = 'e0e0ff' elif line.startswith('diff ') or line.startswith('index '): diff_started = True fgcolor = '808080' elif diff_started: if line.startswith('+++ '): bgcolor = 'e0e0ff' elif line.startswith('@@'): bgcolor = 'e0e0e0' elif line.startswith('+'): bgcolor = 'e0ffe0' elif line.startswith('-'): bgcolor = 'ffe0e0' elif line.startswith('commit '): fgcolor = '808000' elif line.startswith(' '): fgcolor = '404040' # Chop the trailing LF, we don't want it inside. line = html_escape(line[:-1]) if bgcolor or fgcolor: style = 'display:block; white-space:pre;' if bgcolor: style += 'background:#' + bgcolor + ';' if fgcolor: style += 'color:#' + fgcolor + ';' # Use a %s\n" % (style, line) else: line = line + '\n' yield line if self._contains_html_diff: yield '
' html_escape_val = (self.environment.html_in_footer and self._contains_html_diff) footer = self.generate_email_footer(html_escape_val) if not self.environment.html_in_footer: footer = self._wrap_for_html(footer) for line in footer: yield line def get_specific_fromaddr(self): """For kinds of Changes which specify it, return the kind-specific From address to use.""" return None class Revision(Change): """A Change consisting of a single git commit.""" CC_RE = re.compile(r'^\s*C[Cc]:\s*(?P[^#]+@[^\s#]*)\s*(#.*)?$') def __init__(self, reference_change, rev, num, tot): Change.__init__(self, reference_change.environment) self.reference_change = reference_change self.rev = rev self.change_type = self.reference_change.change_type self.refname = self.reference_change.refname self.num = num self.tot = tot self.author = read_git_output(['log', '--no-walk', '--format=%aN <%aE>', self.rev.sha1]) self.recipients = self.environment.get_revision_recipients(self) # -s is short for --no-patch, but -s works on older git's (e.g. 1.7) self.parents = read_git_lines(['show', '-s', '--format=%P', self.rev.sha1])[0].split() self.cc_recipients = '' if self.environment.get_scancommitforcc(): self.cc_recipients = ', '.join(to.strip() for to in self._cc_recipients()) if self.cc_recipients: self.environment.log_msg( 'Add %s to CC for %s' % (self.cc_recipients, self.rev.sha1)) def _cc_recipients(self): cc_recipients = [] message = read_git_output(['log', '--no-walk', '--format=%b', self.rev.sha1]) lines = message.strip().split('\n') for line in lines: m = re.match(self.CC_RE, line) if m: cc_recipients.append(m.group('to')) return cc_recipients def _compute_values(self): values = Change._compute_values(self) oneline = read_git_output( ['log', '--format=%s', '--no-walk', self.rev.sha1] ) max_subject_length = self.environment.get_max_subject_length() if max_subject_length > 0 and len(oneline) > max_subject_length: oneline = oneline[:max_subject_length - 6] + ' [...]' values['rev'] = self.rev.sha1 values['parents'] = ' '.join(self.parents) values['rev_short'] = self.rev.short values['change_type'] = self.change_type values['refname'] = self.refname values['newrev'] = self.rev.sha1 values['short_refname'] = self.reference_change.short_refname values['refname_type'] = self.reference_change.refname_type values['reply_to_msgid'] = self.reference_change.msgid values['thread_index'] = self.reference_change.thread_index values['num'] = self.num values['tot'] = self.tot values['recipients'] = self.recipients if self.cc_recipients: values['cc_recipients'] = self.cc_recipients values['oneline'] = oneline values['author'] = self.author reply_to = self.environment.get_reply_to_commit(self) if reply_to: values['reply_to'] = reply_to return values def generate_email_header(self, **extra_values): for line in self.expand_header_lines( REVISION_HEADER_TEMPLATE, **extra_values ): yield line def generate_browse_link(self, base_url): if '%(' not in base_url: base_url += '%(id)s' url = "".join(self.expand_lines(base_url)) if self._content_type == 'html': for line in self.expand_lines(LINK_HTML_TEMPLATE, html_escape_val=True, browse_url=url): yield line elif self._content_type == 'plain': for line in self.expand_lines(LINK_TEXT_TEMPLATE, html_escape_val=False, browse_url=url): yield line else: raise NotImplementedError("Content-type %s unsupported. Please report it as a bug.") def generate_email_intro(self, html_escape_val=False): for line in self.expand_lines(REVISION_INTRO_TEMPLATE, html_escape_val=html_escape_val): yield line def generate_email_body(self, push): """Show this revision.""" for line in read_git_lines( ['log'] + self.environment.commitlogopts + ['-1', self.rev.sha1], keepends=True, errors='replace'): if line.startswith('Date: ') and self.environment.date_substitute: yield self.environment.date_substitute + line[len('Date: '):] else: yield line def generate_email_footer(self, html_escape_val): return self.expand_lines(REVISION_FOOTER_TEMPLATE, html_escape_val=html_escape_val) def generate_email(self, push, body_filter=None, extra_header_values={}): self._contains_diff() return Change.generate_email(self, push, body_filter, extra_header_values) def get_specific_fromaddr(self): return self.environment.from_commit class ReferenceChange(Change): """A Change to a Git reference. An abstract class representing a create, update, or delete of a Git reference. Derived classes handle specific types of reference (e.g., tags vs. branches). These classes generate the main reference change email summarizing the reference change and whether it caused any any commits to be added or removed. ReferenceChange objects are usually created using the static create() method, which has the logic to decide which derived class to instantiate.""" REF_RE = re.compile(r'^refs\/(?P[^\/]+)\/(?P .*)$') @staticmethod def create(environment, oldrev, newrev, refname): """Return a ReferenceChange object representing the change. Return an object that represents the type of change that is being made. oldrev and newrev should be SHA1s or ZEROS.""" old = GitObject(oldrev) new = GitObject(newrev) rev = new or old # The revision type tells us what type the commit is, combined with # the location of the ref we can decide between # - working branch # - tracking branch # - unannotated tag # - annotated tag m = ReferenceChange.REF_RE.match(refname) if m: area = m.group('area') short_refname = m.group('shortname') else: area = '' short_refname = refname if rev.type == 'tag': # Annotated tag: klass = AnnotatedTagChange elif rev.type == 'commit': if area == 'tags': # Non-annotated tag: klass = NonAnnotatedTagChange elif area == 'heads': # Branch: klass = BranchChange elif area == 'remotes': # Tracking branch: environment.log_warning( '*** Push-update of tracking branch %r\n' '*** - incomplete email generated.' % (refname,) ) klass = OtherReferenceChange else: # Some other reference namespace: environment.log_warning( '*** Push-update of strange reference %r\n' '*** - incomplete email generated.' % (refname,) ) klass = OtherReferenceChange else: # Anything else (is there anything else?) environment.log_warning( '*** Unknown type of update to %r (%s)\n' '*** - incomplete email generated.' % (refname, rev.type,) ) klass = OtherReferenceChange return klass( environment, refname=refname, short_refname=short_refname, old=old, new=new, rev=rev, ) @staticmethod def make_thread_index(): """Return a string appropriate for the Thread-Index header, needed by MS Outlook to get threading right. The format is (base64-encoded): - 1 byte must be 1 - 5 bytes encode a date (hardcoded here) - 16 bytes for a globally unique identifier FIXME: Unfortunately, even with the Thread-Index field, MS Outlook doesn't seem to do the threading reliably (see https://github.com/git-multimail/git-multimail/pull/194). """ thread_index = b'\x01\x00\x00\x12\x34\x56' + uuid.uuid4().bytes return base64.standard_b64encode(thread_index).decode('ascii') def __init__(self, environment, refname, short_refname, old, new, rev): Change.__init__(self, environment) self.change_type = { (False, True): 'create', (True, True): 'update', (True, False): 'delete', }[bool(old), bool(new)] self.refname = refname self.short_refname = short_refname self.old = old self.new = new self.rev = rev self.msgid = make_msgid() self.thread_index = self.make_thread_index() self.diffopts = environment.diffopts self.graphopts = environment.graphopts self.logopts = environment.logopts self.commitlogopts = environment.commitlogopts self.showgraph = environment.refchange_showgraph self.showlog = environment.refchange_showlog self.header_template = REFCHANGE_HEADER_TEMPLATE self.intro_template = REFCHANGE_INTRO_TEMPLATE self.footer_template = FOOTER_TEMPLATE def _compute_values(self): values = Change._compute_values(self) values['change_type'] = self.change_type values['refname_type'] = self.refname_type values['refname'] = self.refname values['short_refname'] = self.short_refname values['msgid'] = self.msgid values['thread_index'] = self.thread_index values['recipients'] = self.recipients values['oldrev'] = str(self.old) values['oldrev_short'] = self.old.short values['newrev'] = str(self.new) values['newrev_short'] = self.new.short if self.old: values['oldrev_type'] = self.old.type if self.new: values['newrev_type'] = self.new.type reply_to = self.environment.get_reply_to_refchange(self) if reply_to: values['reply_to'] = reply_to return values def send_single_combined_email(self, known_added_sha1s): """Determine if a combined refchange/revision email should be sent If there is only a single new (non-merge) commit added by a change, it is useful to combine the ReferenceChange and Revision emails into one. In such a case, return the single revision; otherwise, return None. This method is overridden in BranchChange.""" return None def generate_combined_email(self, push, revision, body_filter=None, extra_header_values={}): """Generate an email describing this change AND specified revision. Iterate over the lines (including the header lines) of an email describing this change. If body_filter is not None, then use it to filter the lines that are intended for the email body. The extra_header_values field is received as a dict and not as **kwargs, to allow passing other keyword arguments in the future (e.g. passing extra values to generate_email_intro() This method is overridden in BranchChange.""" raise NotImplementedError def get_subject(self): template = { 'create': REF_CREATED_SUBJECT_TEMPLATE, 'update': REF_UPDATED_SUBJECT_TEMPLATE, 'delete': REF_DELETED_SUBJECT_TEMPLATE, }[self.change_type] return self.expand(template) def generate_email_header(self, **extra_values): if 'subject' not in extra_values: extra_values['subject'] = self.get_subject() for line in self.expand_header_lines( self.header_template, **extra_values ): yield line def generate_email_intro(self, html_escape_val=False): for line in self.expand_lines(self.intro_template, html_escape_val=html_escape_val): yield line def generate_email_body(self, push): """Call the appropriate body-generation routine. Call one of generate_create_summary() / generate_update_summary() / generate_delete_summary().""" change_summary = { 'create': self.generate_create_summary, 'delete': self.generate_delete_summary, 'update': self.generate_update_summary, }[self.change_type](push) for line in change_summary: yield line for line in self.generate_revision_change_summary(push): yield line def generate_email_footer(self, html_escape_val): return self.expand_lines(self.footer_template, html_escape_val=html_escape_val) def generate_revision_change_graph(self, push): if self.showgraph: args = ['--graph'] + self.graphopts for newold in ('new', 'old'): has_newold = False spec = push.get_commits_spec(newold, self) for line in git_log(spec, args=args, keepends=True): if not has_newold: has_newold = True yield '\n' yield 'Graph of %s commits:\n\n' % ( {'new': 'new', 'old': 'discarded'}[newold],) yield ' ' + line if has_newold: yield '\n' def generate_revision_change_log(self, new_commits_list): if self.showlog: yield '\n' yield 'Detailed log of new commits:\n\n' for line in read_git_lines( ['log', '--no-walk'] + self.logopts + new_commits_list + ['--'], keepends=True, ): yield line def generate_new_revision_summary(self, tot, new_commits_list, push): for line in self.expand_lines(NEW_REVISIONS_TEMPLATE, tot=tot): yield line for line in self.generate_revision_change_graph(push): yield line for line in self.generate_revision_change_log(new_commits_list): yield line def generate_revision_change_summary(self, push): """Generate a summary of the revisions added/removed by this change.""" if self.new.commit_sha1 and not self.old.commit_sha1: # A new reference was created. List the new revisions # brought by the new reference (i.e., those revisions that # were not in the repository before this reference # change). sha1s = list(push.get_new_commits(self)) sha1s.reverse() tot = len(sha1s) new_revisions = [ Revision(self, GitObject(sha1), num=i + 1, tot=tot) for (i, sha1) in enumerate(sha1s) ] if new_revisions: yield self.expand('This %(refname_type)s includes the following new commits:\n') yield '\n' for r in new_revisions: (sha1, subject) = r.rev.get_summary() yield r.expand( BRIEF_SUMMARY_TEMPLATE, action='new', text=subject, ) yield '\n' for line in self.generate_new_revision_summary( tot, [r.rev.sha1 for r in new_revisions], push): yield line else: for line in self.expand_lines(NO_NEW_REVISIONS_TEMPLATE): yield line elif self.new.commit_sha1 and self.old.commit_sha1: # A reference was changed to point at a different commit. # List the revisions that were removed and/or added *from # that reference* by this reference change, along with a # diff between the trees for its old and new values. # List of the revisions that were added to the branch by # this update. Note this list can include revisions that # have already had notification emails; we want such # revisions in the summary even though we will not send # new notification emails for them. adds = list(generate_summaries( '--topo-order', '--reverse', '%s..%s' % (self.old.commit_sha1, self.new.commit_sha1,) )) # List of the revisions that were removed from the branch # by this update. This will be empty except for # non-fast-forward updates. discards = list(generate_summaries( '%s..%s' % (self.new.commit_sha1, self.old.commit_sha1,) )) if adds: new_commits_list = push.get_new_commits(self) else: new_commits_list = [] new_commits = CommitSet(new_commits_list) if discards: discarded_commits = CommitSet(push.get_discarded_commits(self)) else: discarded_commits = CommitSet([]) if discards and adds: for (sha1, subject) in discards: if sha1 in discarded_commits: action = 'discard' else: action = 'omit' yield self.expand( BRIEF_SUMMARY_TEMPLATE, action=action, rev_short=sha1, text=subject, ) for (sha1, subject) in adds: if sha1 in new_commits: action = 'new' else: action = 'add' yield self.expand( BRIEF_SUMMARY_TEMPLATE, action=action, rev_short=sha1, text=subject, ) yield '\n' for line in self.expand_lines(NON_FF_TEMPLATE): yield line elif discards: for (sha1, subject) in discards: if sha1 in discarded_commits: action = 'discard' else: action = 'omit' yield self.expand( BRIEF_SUMMARY_TEMPLATE, action=action, rev_short=sha1, text=subject, ) yield '\n' for line in self.expand_lines(REWIND_ONLY_TEMPLATE): yield line elif adds: (sha1, subject) = self.old.get_summary() yield self.expand( BRIEF_SUMMARY_TEMPLATE, action='from', rev_short=sha1, text=subject, ) for (sha1, subject) in adds: if sha1 in new_commits: action = 'new' else: action = 'add' yield self.expand( BRIEF_SUMMARY_TEMPLATE, action=action, rev_short=sha1, text=subject, ) yield '\n' if new_commits: for line in self.generate_new_revision_summary( len(new_commits), new_commits_list, push): yield line else: for line in self.expand_lines(NO_NEW_REVISIONS_TEMPLATE): yield line for line in self.generate_revision_change_graph(push): yield line # The diffstat is shown from the old revision to the new # revision. This is to show the truth of what happened in # this change. There's no point showing the stat from the # base to the new revision because the base is effectively a # random revision at this point - the user will be interested # in what this revision changed - including the undoing of # previous revisions in the case of non-fast-forward updates. yield '\n' yield 'Summary of changes:\n' for line in read_git_lines( ['diff-tree'] + self.diffopts + ['%s..%s' % (self.old.commit_sha1, self.new.commit_sha1,)], keepends=True, ): yield line elif self.old.commit_sha1 and not self.new.commit_sha1: # A reference was deleted. List the revisions that were # removed from the repository by this reference change. sha1s = list(push.get_discarded_commits(self)) tot = len(sha1s) discarded_revisions = [ Revision(self, GitObject(sha1), num=i + 1, tot=tot) for (i, sha1) in enumerate(sha1s) ] if discarded_revisions: for line in self.expand_lines(DISCARDED_REVISIONS_TEMPLATE): yield line yield '\n' for r in discarded_revisions: (sha1, subject) = r.rev.get_summary() yield r.expand( BRIEF_SUMMARY_TEMPLATE, action='discard', text=subject, ) for line in self.generate_revision_change_graph(push): yield line else: for line in self.expand_lines(NO_DISCARDED_REVISIONS_TEMPLATE): yield line elif not self.old.commit_sha1 and not self.new.commit_sha1: for line in self.expand_lines(NON_COMMIT_UPDATE_TEMPLATE): yield line def generate_create_summary(self, push): """Called for the creation of a reference.""" # This is a new reference and so oldrev is not valid (sha1, subject) = self.new.get_summary() yield self.expand( BRIEF_SUMMARY_TEMPLATE, action='at', rev_short=sha1, text=subject, ) yield '\n' def generate_update_summary(self, push): """Called for the change of a pre-existing branch.""" return iter([]) def generate_delete_summary(self, push): """Called for the deletion of any type of reference.""" (sha1, subject) = self.old.get_summary() yield self.expand( BRIEF_SUMMARY_TEMPLATE, action='was', rev_short=sha1, text=subject, ) yield '\n' def get_specific_fromaddr(self): return self.environment.from_refchange class BranchChange(ReferenceChange): refname_type = 'branch' def __init__(self, environment, refname, short_refname, old, new, rev): ReferenceChange.__init__( self, environment, refname=refname, short_refname=short_refname, old=old, new=new, rev=rev, ) self.recipients = environment.get_refchange_recipients(self) self._single_revision = None def send_single_combined_email(self, known_added_sha1s): if not self.environment.combine_when_single_commit: return None # In the sadly-all-too-frequent usecase of people pushing only # one of their commits at a time to a repository, users feel # the reference change summary emails are noise rather than # important signal. This is because, in this particular # usecase, there is a reference change summary email for each # new commit, and all these summaries do is point out that # there is one new commit (which can readily be inferred by # the existence of the individual revision email that is also # sent). In such cases, our users prefer there to be a combined # reference change summary/new revision email. # # So, if the change is an update and it doesn't discard any # commits, and it adds exactly one non-merge commit (gerrit # forces a workflow where every commit is individually merged # and the git-multimail hook fired off for just this one # change), then we send a combined refchange/revision email. try: # If this change is a reference update that doesn't discard # any commits... if self.change_type != 'update': return None if read_git_lines( ['merge-base', self.old.sha1, self.new.sha1] ) != [self.old.sha1]: return None # Check if this update introduced exactly one non-merge # commit: def split_line(line): """Split line into (sha1, [parent,...]).""" words = line.split() return (words[0], words[1:]) # Get the new commits introduced by the push as a list of # (sha1, [parent,...]) new_commits = [ split_line(line) for line in read_git_lines( [ 'log', '-3', '--format=%H %P', '%s..%s' % (self.old.sha1, self.new.sha1), ] ) ] if not new_commits: return None # If the newest commit is a merge, save it for a later check # but otherwise ignore it merge = None tot = len(new_commits) if len(new_commits[0][1]) > 1: merge = new_commits[0][0] del new_commits[0] # Our primary check: we can't combine if more than one commit # is introduced. We also currently only combine if the new # commit is a non-merge commit, though it may make sense to # combine if it is a merge as well. if not ( len(new_commits) == 1 and len(new_commits[0][1]) == 1 and new_commits[0][0] in known_added_sha1s ): return None # We do not want to combine revision and refchange emails if # those go to separate locations. rev = Revision(self, GitObject(new_commits[0][0]), 1, tot) if rev.recipients != self.recipients: return None # We ignored the newest commit if it was just a merge of the one # commit being introduced. But we don't want to ignore that # merge commit it it involved conflict resolutions. Check that. if merge and merge != read_git_output(['diff-tree', '--cc', merge]): return None # We can combine the refchange and one new revision emails # into one. Return the Revision that a combined email should # be sent about. return rev except CommandError: # Cannot determine number of commits in old..new or new..old; # don't combine reference/revision emails: return None def generate_combined_email(self, push, revision, body_filter=None, extra_header_values={}): values = revision.get_values() if extra_header_values: values.update(extra_header_values) if 'subject' not in extra_header_values: values['subject'] = self.expand(COMBINED_REFCHANGE_REVISION_SUBJECT_TEMPLATE, **values) self._single_revision = revision self._contains_diff() self.header_template = COMBINED_HEADER_TEMPLATE self.intro_template = COMBINED_INTRO_TEMPLATE self.footer_template = COMBINED_FOOTER_TEMPLATE def revision_gen_link(base_url): # revision is used only to generate the body, and # _content_type is set while generating headers. Get it # from the BranchChange object. revision._content_type = self._content_type return revision.generate_browse_link(base_url) self.generate_browse_link = revision_gen_link for line in self.generate_email(push, body_filter, values): yield line def generate_email_body(self, push): '''Call the appropriate body generation routine. If this is a combined refchange/revision email, the special logic for handling this combined email comes from this function. For other cases, we just use the normal handling.''' # If self._single_revision isn't set; don't override if not self._single_revision: for line in super(BranchChange, self).generate_email_body(push): yield line return # This is a combined refchange/revision email; we first provide # some info from the refchange portion, and then call the revision # generate_email_body function to handle the revision portion. adds = list(generate_summaries( '--topo-order', '--reverse', '%s..%s' % (self.old.commit_sha1, self.new.commit_sha1,) )) yield self.expand("The following commit(s) were added to %(refname)s by this push:\n") for (sha1, subject) in adds: yield self.expand( BRIEF_SUMMARY_TEMPLATE, action='new', rev_short=sha1, text=subject, ) yield self._single_revision.rev.short + " is described below\n" yield '\n' for line in self._single_revision.generate_email_body(push): yield line class AnnotatedTagChange(ReferenceChange): refname_type = 'annotated tag' def __init__(self, environment, refname, short_refname, old, new, rev): ReferenceChange.__init__( self, environment, refname=refname, short_refname=short_refname, old=old, new=new, rev=rev, ) self.recipients = environment.get_announce_recipients(self) self.show_shortlog = environment.announce_show_shortlog ANNOTATED_TAG_FORMAT = ( '%(*objectname)\n' '%(*objecttype)\n' '%(taggername)\n' '%(taggerdate)' ) def describe_tag(self, push): """Describe the new value of an annotated tag.""" # Use git for-each-ref to pull out the individual fields from # the tag [tagobject, tagtype, tagger, tagged] = read_git_lines( ['for-each-ref', '--format=%s' % (self.ANNOTATED_TAG_FORMAT,), self.refname], ) yield self.expand( BRIEF_SUMMARY_TEMPLATE, action='tagging', rev_short=tagobject, text='(%s)' % (tagtype,), ) if tagtype == 'commit': # If the tagged object is a commit, then we assume this is a # release, and so we calculate which tag this tag is # replacing try: prevtag = read_git_output(['describe', '--abbrev=0', '%s^' % (self.new,)]) except CommandError: