From ce06a4715eca88589e31b75dd9f8791a240cb94c Mon Sep 17 00:00:00 2001 From: Matthew Poremba Date: Sat, 7 Nov 2020 15:36:54 -0600 Subject: [PATCH] util: Use MAINTAINERS.yaml for valid tags in git hook There is a mismatch between the tags in MAINTAINERS.yaml and the valid_tags in the git hook. This means if a user consults the MAINTAINERS.yaml file to find the appropriate tag, there is a chance of the commit being rejected due to this mismatch. Now that the maintainers file is in yaml format, use the util/maint library to parse the valid tag options. Additional meta tags are added (WIP, RFC) and tags that were previously valid but not in the MAINTAINERS.yaml file. Change-Id: I3de8f0b6f8507aa1afd2118bc4373ac0610cce40 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/37220 Reviewed-by: Andreas Sandberg Reviewed-by: Daniel Carvalho Reviewed-by: Giacomo Travaglini Reviewed-by: Jason Lowe-Power Reviewed-by: Nikos Nikoleris Maintainer: Jason Lowe-Power Tested-by: kokoro --- util/git-commit-msg.py | 24 ++++++++++-------------- util/maint/__init__.py | 1 + 2 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 util/maint/__init__.py diff --git a/util/git-commit-msg.py b/util/git-commit-msg.py index 9cba896ae..2bddf1283 100755 --- a/util/git-commit-msg.py +++ b/util/git-commit-msg.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2019 Inria # All rights reserved @@ -32,6 +32,7 @@ import os import re import sys +from maint.lib import maintainers from style.repo import GitRepo @@ -57,8 +58,8 @@ def _printErrorQuit(error_message): print(""" The first line of a commit must contain one or more gem5 tags separated by -commas (see MAINTAINERS for the possible tags), followed by a colon and a -commit title. There must be no leading nor trailing whitespaces. +commas (see MAINTAINERS.yaml for the possible tags), followed by a colon and +a commit title. There must be no leading nor trailing whitespaces. This header line must then be followed by an empty line. A detailed message, although highly recommended, is not mandatory and can follow that empty line. @@ -85,17 +86,12 @@ def _validateTags(commit_header): """ # List of valid tags - # @todo this is error prone, and should be extracted automatically from - # a file - - valid_tags = ["arch", "arch-arm", "arch-gcn3", - "arch-mips", "arch-power", "arch-riscv", "arch-sparc", "arch-x86", - "base", "configs", "cpu", "cpu-kvm", "cpu-minor", "cpu-o3", - "cpu-simple", "dev", "dev-arm", "dev-hsa", "dev-virtio", "ext", - "fastmodel", "gpu-compute", "learning-gem5", "mem", "mem-cache", - "mem-garnet", "mem-ruby", "misc", "python", "scons", "sim", "sim-se", - "sim-power", "stats", "system", "system-arm", "systemc", "tests", - "util", "RFC", "WIP"] + maintainer_dict = maintainers.Maintainers.from_file() + valid_tags = [tag for tag, _ in maintainer_dict] + + # Remove non-tag 'pmc' and add special tags not in MAINTAINERS.yaml + valid_tags.remove('pmc') + valid_tags.extend(['RFC', 'WIP']) tags = ''.join(commit_header.split(':')[0].split()).split(',') if (any(tag not in valid_tags for tag in tags)): diff --git a/util/maint/__init__.py b/util/maint/__init__.py new file mode 100644 index 000000000..e5a0d9b48 --- /dev/null +++ b/util/maint/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/env python3 -- 2.30.2