From 259fe1984ae52ab2dd869a765dff518cadcef7f3 Mon Sep 17 00:00:00 2001 From: Nick Dimiduk Date: Thu, 29 Oct 2020 09:21:18 -0700 Subject: [PATCH] HBASE-24845 Git/Jira Release Audit: limit branches when building audit db (#2238) Populating the audit database with release tag information from git is time consuming. Until that's sorted out, give the user a flag for limiting which branches they want to be reviewed. Signed-off-by: Andrew Purtell --- dev-support/git-jira-release-audit/README.md | 9 +++++++-- .../git-jira-release-audit/git_jira_release_audit.py | 11 ++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/dev-support/git-jira-release-audit/README.md b/dev-support/git-jira-release-audit/README.md index 396128ad55d..6ea575e16fd 100644 --- a/dev-support/git-jira-release-audit/README.md +++ b/dev-support/git-jira-release-audit/README.md @@ -62,6 +62,7 @@ usage: git_jira_release_audit.py [-h] [--populate-from-git POPULATE_FROM_GIT] [--release-line-regexp RELEASE_LINE_REGEXP] [--parse-release-tags PARSE_RELEASE_TAGS] [--fallback-actions-path FALLBACK_ACTIONS_PATH] + [--branch-filter-regexp BRANCH_FILTER_REGEXP] [--jira-url JIRA_URL] --branch-1-fix-version BRANCH_1_FIX_VERSION --branch-2-fix-version BRANCH_2_FIX_VERSION @@ -119,6 +120,9 @@ Interactions with the Git repo: --fallback-actions-path FALLBACK_ACTIONS_PATH Path to a file containing _DB.Actions applicable to specific git shas. (default: fallback_actions.csv) + --branch-filter-regexp BRANCH_FILTER_REGEXP + Limit repo parsing to branch names that match this + filter expression. (default: .*) --branch-1-fix-version BRANCH_1_FIX_VERSION The Jira fixVersion used to indicate an issue is committed to the specified release line branch @@ -175,8 +179,9 @@ fetch from Jira 100%|███████████████████ Optionally, the database can be build to include release tags, by specifying `--parse-release-tags=true`. This is more time-consuming, but is necessary for -auditing discrepancies between git and Jira. Running the same command but -including this flag looks like this: +auditing discrepancies between git and Jira. Optionally, limit the branches +under consideration by specifying a regex filter with `--branch-filter-regexp`. +Running the same command but including this flag looks like this: ```shell script origin/branch-1 100%|███████████████████████████████████████| 4084/4084 [08:58<00:00, 7.59 commit/s] diff --git a/dev-support/git-jira-release-audit/git_jira_release_audit.py b/dev-support/git-jira-release-audit/git_jira_release_audit.py index db2788d081d..358dfd53350 100644 --- a/dev-support/git-jira-release-audit/git_jira_release_audit.py +++ b/dev-support/git-jira-release-audit/git_jira_release_audit.py @@ -199,13 +199,14 @@ class _RepoReader: _identify_amend_jira_id_pattern = re.compile(r'^amend (.+)', re.IGNORECASE) def __init__(self, db, fallback_actions_path, remote_name, development_branch, - release_line_regexp, parse_release_tags, **_kwargs): + release_line_regexp, branch_filter_regexp, parse_release_tags, **_kwargs): self._db = db self._repo = _RepoReader._open_repo() self._fallback_actions = _RepoReader._load_fallback_actions(fallback_actions_path) self._remote_name = remote_name self._development_branch = development_branch self._release_line_regexp = release_line_regexp + self._branch_filter_regexp = branch_filter_regexp self._parse_release_tags = parse_release_tags @property @@ -364,6 +365,10 @@ class _RepoReader: release_branch (str): The name of the ref whose history is to be parsed. """ global MANAGER + branch_filter_pattern = re.compile('%s/%s' % (self._remote_name, self._branch_filter_regexp)) + if not branch_filter_pattern.match(release_branch): + return + commits = list(self._repo.iter_commits( "%s...%s" % (origin_commit.hexsha, release_branch), reverse=True)) LOG.info("%s has %d commits since its origin at %s.", release_branch, len(commits), @@ -638,6 +643,10 @@ class Auditor: '--fallback-actions-path', help='Path to a file containing _DB.Actions applicable to specific git shas.', default='fallback_actions.csv') + git_repo_group.add_argument( + '--branch-filter-regexp', + help='Limit repo parsing to branch names that match this filter expression.', + default=r'.*') jira_group = parser.add_argument_group('Interactions with Jira') jira_group.add_argument( '--jira-url',