From e2dc096305cf663ea836d88432cbc6cc14677a03 Mon Sep 17 00:00:00 2001 From: Quan Zhou Date: Mon, 30 May 2022 18:47:22 +0200 Subject: [PATCH] [git] Add more connectors to find out pair programming authors This code adds more connectors to find out pair programming users more accurately when `pair-programming` is enabled. Connectors updated: - `[aA][nN][dD]` - `&` - `+` Tests updated accordingly. Signed-off-by: Quan Zhou --- grimoire_elk/enriched/git.py | 2 +- ...nectors-to-find-out-pair-programming-authors.yml | 13 +++++++++++++ tests/data/git.json | 12 ++++++------ tests/test_git.py | 2 +- 4 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 releases/unreleased/add-more-connectors-to-find-out-pair-programming-authors.yml diff --git a/grimoire_elk/enriched/git.py b/grimoire_elk/enriched/git.py index be71f2a0f..0d2101180 100644 --- a/grimoire_elk/enriched/git.py +++ b/grimoire_elk/enriched/git.py @@ -78,7 +78,7 @@ class GitEnrich(Enrich): # REGEX to extract authors from a multi author commit: several authors present # in the Author field in the commit. Used if self.pair_programming is True - AUTHOR_P2P_REGEX = re.compile(r'(?P.* .*) and (?P.* .*) (?P.*)') + AUTHOR_P2P_REGEX = re.compile(r'(?P.* .*) ([aA][nN][dD]|&|\+) (?P.* .*) (?P.*)') AUTHOR_P2P_NEW_REGEX = re.compile(r"Co-authored-by:(?P.* .*)<(?P.*)>\n?") # REGEX to extract authors from the commit diff --git a/releases/unreleased/add-more-connectors-to-find-out-pair-programming-authors.yml b/releases/unreleased/add-more-connectors-to-find-out-pair-programming-authors.yml new file mode 100644 index 000000000..beb0020f4 --- /dev/null +++ b/releases/unreleased/add-more-connectors-to-find-out-pair-programming-authors.yml @@ -0,0 +1,13 @@ +--- +title: Pair programming regular expression improvement +category: fixed +author: Quan Zhou +issue: null +notes: > + The regular expression to detect pair programming authors in git + datasource has been improved adding more connectors. + + The following list shows the current connectors: + - `[aA][nN][dD]` + - `&` + - `+` diff --git a/tests/data/git.json b/tests/data/git.json index d38f25184..67636f8e6 100644 --- a/tests/data/git.json +++ b/tests/data/git.json @@ -109,9 +109,9 @@ "backend_version": "0.8.10", "category": "commit", "data": { - "Author": "Eduardo Morais ", + "Author": "Eduardo Morais & Zhongpeng Lin ", "AuthorDate": "Tue Aug 14 14:33:27 2012 -0300", - "Commit": "Eduardo Morais ", + "Commit": "Eduardo Morais & Zhongpeng Lin ", "CommitDate": "Tue Aug 14 14:33:27 2012 -0300", "commit": "7debcf8a2f57f86663809c58b5c07a398be7674c", "files": [ @@ -147,9 +147,9 @@ "backend_version": "0.8.10", "category": "commit", "data": { - "Author": "Eduardo Morais ", + "Author": "Eduardo Morais + Zhongpeng Lin ", "AuthorDate": "Tue Aug 14 14:35:02 2012 -0300", - "Commit": "Eduardo Morais ", + "Commit": "Eduardo Morais + Zhongpeng Lin ", "CommitDate": "Tue Aug 14 14:35:02 2012 -0300", "commit": "c0d66f92a95e31c77be08dc9d0f11a16715d1885", "files": [ @@ -200,9 +200,9 @@ "backend_version": "0.8.10", "category": "commit", "data": { - "Author": "Eduardo Morais ", + "Author": "Eduardo Morais And Zhongpeng Lin ", "AuthorDate": "Tue Aug 14 14:45:51 2012 -0300", - "Commit": "Eduardo Morais ", + "Commit": "Eduardo Morais And Zhongpeng Lin ", "CommitDate": "Tue Aug 14 14:45:51 2012 -0300", "commit": "c6ba8f7a1058db3e6b4bc6f1090e932b107605fb", "files": [ diff --git a/tests/test_git.py b/tests/test_git.py index 465d13aff..8cf3a9cc0 100644 --- a/tests/test_git.py +++ b/tests/test_git.py @@ -156,7 +156,7 @@ def test_raw_to_enrich_pair_programming(self): result = self._test_raw_to_enrich(pair_programming=True) self.assertEqual(result['raw'], 11) - self.assertEqual(result['enrich'], 13) + self.assertEqual(result['enrich'], 16) enrich_backend = self.connectors[self.connector][2](pair_programming=True) url = self.es_con + "/" + self.enrich_index + "/_search?size=20"