From 48a31b5c2ec23d1c6280136e3cb01dd5769b7328 Mon Sep 17 00:00:00 2001 From: Quan Zhou Date: Wed, 26 Oct 2022 12:11:02 +0200 Subject: [PATCH] [enriched/git] Add more git commit meta fields This code extracts more authors meta info: - Approved-by - Co-authored-by - Merged-by For each one it will creates 10 new fields. - suffixes: `_bots`, `_domains`, `_names`, `_org_names`, `_uuids` - prefix: `non_authored_` Example of Merged-by: - merged_by_multi_bots - merged_by_multi_domains - merged_by_multi_names - merged_by_multi_org_names - merged_by_multi_uuids - non_authored_merged_by_multi_bots - non_authored_merged_by_multi_domains - non_authored_merged_by_multi_names - non_authored_merged_by_multi_org_names - non_authored_merged_by_multi_uuids Signed-off-by: Quan Zhou --- grimoire_elk/enriched/git.py | 5 ++-- .../git-extracts-more-authors-meta-info.yml | 23 ++++++++++++++ tests/data/git.json | 2 +- tests/test_git.py | 30 +++++++++++++++++++ 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 releases/unreleased/git-extracts-more-authors-meta-info.yml diff --git a/grimoire_elk/enriched/git.py b/grimoire_elk/enriched/git.py index 9d116184b..e35427da5 100644 --- a/grimoire_elk/enriched/git.py +++ b/grimoire_elk/enriched/git.py @@ -86,8 +86,9 @@ class GitEnrich(Enrich): GIT_AOC_ENRICHED = "git_aoc-enriched" roles = ['Author', 'Commit'] - meta_fields = ['acked_by_multi', 'co_developed_by_multi', 'reported_by_multi', 'reviewed_by_multi', - 'signed_off_by_multi', 'suggested_by_multi', 'tested_by_multi'] + meta_fields = ['acked_by_multi', 'approved_by_multi', 'co_authored_by_multi', 'co_developed_by_multi', + 'merged_by_multi', 'reported_by_multi', 'reviewed_by_multi', 'signed_off_by_multi', + 'suggested_by_multi', 'tested_by_multi'] meta_fields_suffixes = ['_bots', '_domains', '_names', '_org_names', '_uuids'] meta_non_authored_prefix = 'non_authored_' diff --git a/releases/unreleased/git-extracts-more-authors-meta-info.yml b/releases/unreleased/git-extracts-more-authors-meta-info.yml new file mode 100644 index 000000000..75fab5be2 --- /dev/null +++ b/releases/unreleased/git-extracts-more-authors-meta-info.yml @@ -0,0 +1,23 @@ +--- +title: Development and reviewing contributors fields for Git items +category: added +author: Quan Zhou +issue: null +notes: > + New information about the participants during the development and the + reviewing processes are available in `Git` items. The Git backend extracts + these data from `Approved-by`, `Co-authored-by`, and `Merged-by` + trailers that some commit messages might include. For each one of these + trailers, new fields will be available with the suffixes: `_bots`, `_domains`, + `_names`, `_org_names`, and `_uuids`. Also for each one of these suffixes, + there will be extra fields with the prefix `non_authored_`. + This is an example of the fields available for the the trailer `Merged-by`: + - merged_by_multi_bots + - merged_by_multi_domains + - merged_by_multi_names + - merged_by_multi_org_names + - merged_by_multi_uuids + - non_authored_merged_by_multi_bots + - non_authored_merged_by_multi_domains + - non_authored_merged_by_multi_names + - non_authored_merged_by_multi_org_names diff --git a/tests/data/git.json b/tests/data/git.json index 67636f8e6..df7b7d7e1 100644 --- a/tests/data/git.json +++ b/tests/data/git.json @@ -379,7 +379,7 @@ "removed": "0" } ], - "message": "Merge branch 'lzp'\n\nConflicts:\n\taaa/otherthing\nSigned-off-by: Owl Capone \nReviewed-by: Owl Capone \nSigned-off-by: Owl Second ", + "message": "Merge branch 'lzp'\n\nConflicts:\n\taaa/otherthing\nSigned-off-by: Owl Capone \nReviewed-by: Owl Capone \nSigned-off-by: Owl Second \nMerged-by: Owl Third \nCo-authored-by: OwlBot \nApproved-by: Owl Third ", "parents": [ "ce8e0b86a1e9877f42fe9453ede418519115f367", "51a3b654f252210572297f47597b31527c475fb8" diff --git a/tests/test_git.py b/tests/test_git.py index 70e25ff58..8976ff6b7 100644 --- a/tests/test_git.py +++ b/tests/test_git.py @@ -122,6 +122,21 @@ def test_raw_to_enrich(self): self.assertListEqual(eitem['suggested_by_multi_names'], []) self.assertListEqual(eitem['tested_by_multi_names'], []) self.assertListEqual(eitem['non_authored_signed_off_by_multi_names'], []) + self.assertListEqual(eitem['approved_by_multi_names'], []) + self.assertListEqual(eitem['approved_by_multi_domains'], []) + self.assertListEqual(eitem['approved_by_multi_bots'], []) + self.assertListEqual(eitem['approved_by_multi_org_names'], []) + self.assertListEqual(eitem['approved_by_multi_uuids'], []) + self.assertListEqual(eitem['co_authored_by_multi_names'], []) + self.assertListEqual(eitem['co_authored_by_multi_domains'], []) + self.assertListEqual(eitem['merged_by_multi_names'], []) + self.assertListEqual(eitem['merged_by_multi_domains'], []) + self.assertListEqual(eitem['non_authored_approved_by_multi_names'], []) + self.assertListEqual(eitem['non_authored_approved_by_multi_domains'], []) + self.assertListEqual(eitem['non_authored_co_authored_by_multi_names'], []) + self.assertListEqual(eitem['non_authored_co_authored_by_multi_domains'], []) + self.assertListEqual(eitem['non_authored_merged_by_multi_names'], []) + self.assertListEqual(eitem['non_authored_merged_by_multi_domains'], []) item = self.items[8] eitem = enrich_backend.get_rich_item(item) @@ -148,6 +163,21 @@ def test_raw_to_enrich(self): self.assertListEqual(eitem['suggested_by_multi_names'], []) self.assertListEqual(eitem['tested_by_multi_names'], []) self.assertListEqual(eitem['non_authored_signed_off_by_multi_names'], ['Owl Second']) + self.assertListEqual(eitem['approved_by_multi_names'], ['Owl Third']) + self.assertListEqual(eitem['approved_by_multi_domains'], ['third.io']) + self.assertListEqual(eitem['approved_by_multi_bots'], [False]) + self.assertListEqual(eitem['approved_by_multi_org_names'], ['Unknown']) + self.assertListEqual(eitem['approved_by_multi_uuids'], ['1bdac6c64760c1027a3777c9ba22adddb0e97c5e']) + self.assertListEqual(eitem['co_authored_by_multi_names'], ['OwlBot']) + self.assertListEqual(eitem['co_authored_by_multi_domains'], ['boss.io']) + self.assertListEqual(eitem['merged_by_multi_names'], ['Owl Third']) + self.assertListEqual(eitem['merged_by_multi_domains'], ['third.io']) + self.assertListEqual(eitem['non_authored_approved_by_multi_names'], ['Owl Third']) + self.assertListEqual(eitem['non_authored_approved_by_multi_domains'], ['third.io']) + self.assertListEqual(eitem['non_authored_co_authored_by_multi_names'], ['OwlBot']) + self.assertListEqual(eitem['non_authored_co_authored_by_multi_domains'], ['boss.io']) + self.assertListEqual(eitem['non_authored_merged_by_multi_names'], ['Owl Third']) + self.assertListEqual(eitem['non_authored_merged_by_multi_domains'], ['third.io']) aliases = self.enrich_backend.elastic.list_aliases() self.assertListEqual(self.enrich_aliases, list(aliases.keys()))