On Sat, Jan 11, 2020 at 11:03:02AM +0100, Jakub Jelinek wrote: > Here it is in patch form (against Joseph's git-hooks copy), but untested > (both because the repo isn't converted yet, basepoints don't exist there > either and because not sure how exactly it can be tested in a dry-run, say > sending me mail instead of to the public list etc.). > So, all I did test is some simple thing in python3 interactively because > it is close to 20 years since I used python regularly.
This is what I've actually committed after testing it (in gcc-reposurgeon-8.git) and Joseph's approval. Example how such mail looks like: https://gcc.gnu.org/ml/gcc-cvs/2020-01/msg00396.html and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93218#c3 for bugzilla comment. Commits to branches other than master or releases/gcc-* are unaffected. If we get the https://gcc.gnu.org/g: redirector working, we should change the URLs emitted in both gcc-cvs mails and in bugzilla, because at least in bugzilla the 87 chars long URL is too long and wraps around. diff --git a/hooks/updates/__init__.py b/hooks/updates/__init__.py index c5d8181..9d9e1dc 100644 --- a/hooks/updates/__init__.py +++ b/hooks/updates/__init__.py @@ -299,6 +299,19 @@ class AbstractUpdate(object): # name in full to label the branch name. branch = '(%s)' % self.ref_name + # GCC monotonically increasing commit ids. + rev_id = '' + if (self.email_info.project_name.startswith('gcc') + and (self.short_ref_name == 'master' + or self.short_ref_name.startswith('releases/gcc-'))): + rev_id = git.describe(commit.rev, all=True, abbrev='40', + match='basepoints/gcc-[0-9]*') + if rev_id.startswith('basepoints/gcc-'): + rev_id = 'r' + rev_id[len('basepoints/gcc-'):] + branch = ' ' + rev_id[:rev_id.find('-g')] + else: + rev_id = '' + subject = '[%(repo)s%(branch)s] %(subject)s' % { 'repo': self.email_info.project_name, 'branch': branch, @@ -322,6 +335,10 @@ class AbstractUpdate(object): # by stripping it from the output. body = git.log(commit.rev, max_count="1") + '\n' + + if rev_id: + body = re.sub(r'^commit ' + commit.rev, 'commit ' + rev_id, + body, 1, re.M) if git_config('hooks.commit-url') is not None: url_info = {'rev': commit.rev, 'ref_name': self.ref_name} Jakub