From 105dd6d1e8c83e137e383e6b928efcda7c7be103 Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Tue, 21 Mar 2017 16:47:39 +0100 Subject: [PATCH] aclmanager: do not keep old stable sections around When patching ACL files, rather than just add a section for stable/$newseries, we should also delete old stable/$series sections. Otherwise around $newseries release time, stable/$series would be owned by release managers again. Change-Id: I1fdc8e370f0f56df54ba27736046d7d6893ca240 --- tools/aclmanager.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/aclmanager.py b/tools/aclmanager.py index 619da69a23..364682f977 100755 --- a/tools/aclmanager.py +++ b/tools/aclmanager.py @@ -20,6 +20,7 @@ import argparse import getpass import os +import re import sys import requests @@ -106,13 +107,32 @@ label-Workflow = -1..+1 group {group} else: with open(fullfilename) as aclfile: hit = False + skip = False for line in aclfile: - if line.startswith("[receive]"): + # Skip until start of next section if in skip mode + if skip: + if line.startswith('['): + skip = False + else: + continue + + if re.match('^\[access "refs/heads/stable/[a-z]', line): + # We just hit a specific stable section. + # Skip the file until the next section starts. + skip = True + continue + + if line.startswith("[receive]") and not hit: + # We reached the [receive] section: let's place + # our specific stable section here. newcontent += blob.format( branch=args.series, group=group) hit = True + + # Copy the current line over newcontent += line + if not hit: print("Could not update %s automatically" % fullfilename)