07.10.2019 18:55, Cornelia Huck wrote: > On Tue, 1 Oct 2019 18:52:54 +0300 > Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> wrote: > >> Add script to automatically commit tree-wide changes per-subsystem. >> >> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> >> --- >> >> CC: kw...@redhat.com >> CC: mre...@redhat.com >> CC: js...@redhat.com >> CC: f...@euphon.net >> CC: s...@weilnetz.de >> CC: codypr...@gmail.com >> CC: marcandre.lur...@redhat.com >> CC: pbonz...@redhat.com >> CC: gr...@kaod.org >> CC: sundeep.l...@gmail.com >> CC: peter.mayd...@linaro.org >> CC: stefa...@redhat.com >> CC: pbur...@wavecomp.com >> CC: arik...@wavecomp.com >> CC: berra...@redhat.com >> CC: ehabk...@redhat.com >> CC: da...@gibson.dropbear.id.au >> CC: c...@kaod.org >> CC: m...@redhat.com >> CC: marcel.apfelb...@gmail.com >> CC: mark.cave-ayl...@ilande.co.uk >> CC: yuval.sh...@oracle.com >> CC: coh...@redhat.com >> CC: far...@linux.ibm.com >> CC: r...@twiddle.net >> CC: da...@redhat.com >> CC: pa...@linux.ibm.com >> CC: borntrae...@de.ibm.com >> CC: kra...@redhat.com >> CC: alex.william...@redhat.com >> CC: and...@aj.id.au >> CC: j...@jms.id.au >> CC: ebl...@redhat.com >> CC: arm...@redhat.com >> CC: mdr...@linux.vnet.ibm.com >> CC: quint...@redhat.com >> CC: dgilb...@redhat.com >> CC: jasow...@redhat.com >> CC: qemu-bl...@nongnu.org >> CC: integrat...@gluster.org >> CC: qemu-...@nongnu.org >> CC: qemu-...@nongnu.org >> CC: qemu-s3...@nongnu.org >> >> >> python/commit-per-subsystem.py | 69 ++++++++++++++++++++++++++++++++++ >> 1 file changed, 69 insertions(+) >> create mode 100755 python/commit-per-subsystem.py >> >> diff --git a/python/commit-per-subsystem.py b/python/commit-per-subsystem.py >> new file mode 100755 >> index 0000000000..d8442d9ea3 >> --- /dev/null >> +++ b/python/commit-per-subsystem.py >> @@ -0,0 +1,69 @@ >> +#!/usr/bin/env python3 >> +# >> +# Copyright (c) 2019 Virtuozzo International GmbH >> +# >> +# This program is free software; you can redistribute it and/or modify >> +# it under the terms of the GNU General Public License as published by >> +# the Free Software Foundation; either version 2 of the License, or >> +# (at your option) any later version. >> +# >> +# 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 <http://www.gnu.org/licenses/>. >> +# >> + >> +import subprocess >> +import sys >> + >> + >> +def git_add(pattern): >> + subprocess.run(['git', 'add', pattern]) >> + >> + >> +def git_commit(msg): >> + subprocess.run(['git', 'commit', '-m', msg], capture_output=True) >> + >> + >> +maintainers = sys.argv[1] >> +message = sys.argv[2].strip() >> + >> +subsystem = None >> + >> +shortnames = { >> + 'Block layer core': 'block', >> + 'ARM cores': 'arm', >> + 'Network Block Device (NBD)': 'nbd', >> + 'Command line option argument parsing': 'cmdline', >> + 'Character device backends': 'chardev', >> + 'S390 general architecture support': 's390' >> +} >> + >> + >> +def commit(): >> + if subsystem: >> + msg = subsystem >> + if msg in shortnames: >> + msg = shortnames[msg] >> + msg += ': ' + message >> + git_commit(msg) >> + >> + >> +with open(maintainers) as f: >> + for line in f: >> + line = line.rstrip() >> + if not line: >> + continue >> + if len(line) >= 2 and line[1] == ':': >> + if line[0] == 'F' and line[3:] not in ['*', '*/']: >> + git_add(line[3:]) >> + else: >> + # new subsystem start >> + commit() >> + >> + subsystem = line >> + >> +commit() > > Hm... I'm not sure about the purpose of this script (and my python is > rather weak)... is this supposed to collect all changes covered by a > subsystem F: pattern into one patch?
Yes > If so, what happens to files > covered by multiple sections? > Hmm, they just go to the first of these sections, mentioned in MAINTAINERS. Is it bad I don't know, but I tried to automate it somehow. Anyway, I myself can't have better idea about how to organize patches to the subsystems which I don't know. -- Best regards, Vladimir