Skip to contentSkip to conversation

get_maintainer: Gracefully handle files with authors but no signers

PATCH Superseded David Matlack 2 participants 3 messages Sep 22, 2022 – Sep 27, 2022 GET_MAINTAINER script

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 get_maintainer: Gracefully handle files with authors but no signers

Gracefully handle the case where a file has no signers (e.g. has not been modified within the last year) but does have authors (e.g. because there are local commits that modifies the file without Signed-off-by tags). This scenario could happen for developers whose workflow is to add Signed-off-by tags as part of git-format-patch rather than as part of git-commit.

Today this scenario results in the following non-sensical output from get_maintainer.pl:

Bad divisor in main::vcs_assign: 0
"GitAuthor: David Matlack" <[email protected]> (authored:1/1=100%,added_lines:9/9=100%,removed_lines:3/3=100%)

There are two issues with this output: the "Bad divisor" error and the garbled author name. Both stem from this line in vcs_find_signers():

  return (0, \@signatures, \@authors, \@stats) if !@signatures;

Returning 0 for the number of commits and a non-empty list for the authors results in the "Bad divisor". The garbled author name comes from the fact that @authors is the raw, unparsed, output line from git-log. Code later in vcs_find_signers() actually parses out the name and drops the "GitAuthor: " prefix.

Fix this by returning an empty list instead of @authors and @stats to make them coherent with the fact that commits is 0.

---
 scripts/get_maintainer.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/get_maintainer.pl +1 -1
index ab123b498fd9..69f0e1ac9f90 100755
@@ -1605,7 +1605,7 @@ sub vcs_find_signers {
 
 #    print("stats: <@stats>\n");
 
-    return (0, \@signatures, \@authors, \@stats) if !@signatures;
+    return (0, (), (), ()) if !@signatures;
 
     save_commits_by_author(@lines) if ($interactive);
     save_commits_by_signer(@lines) if ($interactive);

base-commit: bf682942cd26ce9cd5e87f73ae099b383041e782

Signature · 1 line
2.37.3.998.g577e59143f-goog
maintainer
#1 lore raw
Quoted 6 lines · David Matlack

Gracefully handle the case where a file has no signers (e.g. has not been modified within the last year) but does have authors (e.g. because there are local commits that modifies the file without Signed-off-by tags). This scenario could happen for developers whose workflow is to add Signed-off-by tags as part of git-format-patch rather than as part of git-commit.

I think that's a poor process.

Quoted 5 lines

Today this scenario results in the following non-sensical output from get_maintainer.pl:

Bad divisor in main::vcs_assign: 0
"GitAuthor: David Matlack" <[email protected]> (authored:1/1=100%,added_lines:9/9=100%,removed_lines:3/3=100%)

Interesting...

Quoted 4 lines

There are two issues with this output: the "Bad divisor" error and the garbled author name. Both stem from this line in vcs_find_signers():

  return (0, \@signatures, \@authors, \@stats) if !@signatures;

[]

Quoted 8 lines

Returning 0 for the number of commits and a non-empty list for the authors results in the "Bad divisor". The garbled author name comes from the fact that @authors is the raw, unparsed, output line from git-log. Code later in vcs_find_signers() actually parses out the name and drops the "GitAuthor: " prefix.

Fix this by returning an empty list instead of @authors and @stats to make them coherent with the fact that commits is 0.

[]

scripts/get_maintainer.pl

Quoted 1 line
scripts/get_maintainer.pl +0 -0

[]

scripts/get_maintainer.pl sub vcs_find_signers { · line 1608

Quoted 6 lines
scripts/get_maintainer.pl +1 -1
@@ -1605,7 +1605,7 @@ sub vcs_find_signers {
 
 #    print("stats: <@stats>\n");
 
-    return (0, \@signatures, \@authors, \@stats) if !@signatures;
+    return (0, (), (), ()) if !@signatures;

There's probably some better mechanism, not sure what it is though as I don't have equivalent commits in the actual tree.

And I think you need \() and not () as what's returned is a reference to an array and not an array or maybe use undef.

Quoted 2 lines
scripts/get_maintainer.pl +0 -0
     save_commits_by_author(@lines) if ($interactive);
     save_commits_by_signer(@lines) if ($interactive);
#2 lore raw
Quoted 10 lines · Joe Perches
Quoted 6 lines · David Matlack

Gracefully handle the case where a file has no signers (e.g. has not been modified within the last year) but does have authors (e.g. because there are local commits that modifies the file without Signed-off-by tags). This scenario could happen for developers whose workflow is to add Signed-off-by tags as part of git-format-patch rather than as part of git-commit.

I think that's a poor process.

I don't disagree, and personally I have changed my own workflow to add sign-offs at commit time.

Quoted 29 lines
Quoted 6 lines

Today this scenario results in the following non-sensical output from get_maintainer.pl:

Bad divisor in main::vcs_assign: 0
"GitAuthor: David Matlack" <[email protected]> (authored:1/1=100%,added_lines:9/9=100%,removed_lines:3/3=100%)

Interesting...

Quoted 4 lines

There are two issues with this output: the "Bad divisor" error and the garbled author name. Both stem from this line in vcs_find_signers():

  return (0, \@signatures, \@authors, \@stats) if !@signatures;

[]

Quoted 8 lines

Returning 0 for the number of commits and a non-empty list for the authors results in the "Bad divisor". The garbled author name comes from the fact that @authors is the raw, unparsed, output line from git-log. Code later in vcs_find_signers() actually parses out the name and drops the "GitAuthor: " prefix.

Fix this by returning an empty list instead of @authors and @stats to make them coherent with the fact that commits is 0.

[]

scripts/get_maintainer.pl

Quoted 1 line
scripts/get_maintainer.pl +0 -0

[]

Quoted 4 lines
scripts/get_maintainer.pl +0 -0
@@ -1605,7 +1605,7 @@ sub vcs_find_signers {
 
 #    print("stats: <@stats>\n");
 
Quoted 8 lines

scripts/get_maintainer.pl sub vcs_find_signers { · line 1608

Quoted 2 lines
scripts/get_maintainer.pl +1 -1
-    return (0, \@signatures, \@authors, \@stats) if !@signatures;
+    return (0, (), (), ()) if !@signatures;

There's probably some better mechanism, not sure what it is though as I don't have equivalent commits in the actual tree.

And I think you need \() and not () as what's returned is a reference to an array and not an array or maybe use undef.

Ack, will do in v2.

Quoted 4 lines
Quoted 3 lines
scripts/get_maintainer.pl +0 -0
     save_commits_by_author(@lines) if ($interactive);
     save_commits_by_signer(@lines) if ($interactive);