Skip to content

Commit

Permalink
[git] Add more connectors to find out pair programming authors
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
zhquan committed May 30, 2022
1 parent badd7d5 commit c0e80b8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion grimoire_elk/enriched/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<first_authors>.* .*) and (?P<last_author>.* .*) (?P<email>.*)')
AUTHOR_P2P_REGEX = re.compile(r'(?P<first_authors>.* .*) ([aA][nN][dD]|&|\+) (?P<last_author>.* .*) (?P<email>.*)')
AUTHOR_P2P_NEW_REGEX = re.compile(r"Co-authored-by:(?P<first_authors>.* .*)<(?P<email>.*)>\n?")

# REGEX to extract authors from the commit
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Add more connectors to find out pair programming authors
category: fixed
author: Quan Zhou <[email protected]>
issue: null
notes: >
Adds more connectors to find out pair programming users more
accurately.
Connectors updated:
- `[aA][nN][dD]`
- `&`
- `+`
12 changes: 6 additions & 6 deletions tests/data/git.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@
"backend_version": "0.8.10",
"category": "commit",
"data": {
"Author": "Eduardo Morais <[email protected]>",
"Author": "Eduardo Morais & Zhongpeng Lin <[email protected]>",
"AuthorDate": "Tue Aug 14 14:33:27 2012 -0300",
"Commit": "Eduardo Morais <[email protected]>",
"Commit": "Eduardo Morais & Zhongpeng Lin <[email protected]>",
"CommitDate": "Tue Aug 14 14:33:27 2012 -0300",
"commit": "7debcf8a2f57f86663809c58b5c07a398be7674c",
"files": [
Expand Down Expand Up @@ -147,9 +147,9 @@
"backend_version": "0.8.10",
"category": "commit",
"data": {
"Author": "Eduardo Morais <[email protected]>",
"Author": "Eduardo Morais + Zhongpeng Lin <[email protected]>",
"AuthorDate": "Tue Aug 14 14:35:02 2012 -0300",
"Commit": "Eduardo Morais <[email protected]>",
"Commit": "Eduardo Morais + Zhongpeng Lin <[email protected]>",
"CommitDate": "Tue Aug 14 14:35:02 2012 -0300",
"commit": "c0d66f92a95e31c77be08dc9d0f11a16715d1885",
"files": [
Expand Down Expand Up @@ -200,9 +200,9 @@
"backend_version": "0.8.10",
"category": "commit",
"data": {
"Author": "Eduardo Morais <[email protected]>",
"Author": "Eduardo Morais And Zhongpeng Lin <[email protected]>",
"AuthorDate": "Tue Aug 14 14:45:51 2012 -0300",
"Commit": "Eduardo Morais <[email protected]>",
"Commit": "Eduardo Morais And Zhongpeng Lin <[email protected]>",
"CommitDate": "Tue Aug 14 14:45:51 2012 -0300",
"commit": "c6ba8f7a1058db3e6b4bc6f1090e932b107605fb",
"files": [
Expand Down
6 changes: 3 additions & 3 deletions tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -377,10 +377,10 @@ def test_onion_study(self):

time.sleep(1)

url = self.es_con + "/test_git_onion/_search?size=20"
url = self.es_con + "/test_git_onion/_search?size=40"
response = requests.get(url, verify=False).json()
hits = response['hits']['hits']
self.assertEqual(len(hits), 16)
self.assertEqual(len(hits), 24)
for hit in hits:
source = hit['_source']
self.assertIn('timeframe', source)
Expand Down

0 comments on commit c0e80b8

Please sign in to comment.