Skip to content

"Read" the "What's cooking" mails and map the comments to the PRs - #458

Merged
webstech merged 3 commits into
gitgitgadget:mainfrom
dscho:whats-cooking
Feb 23, 2021
Merged

webstech merged 3 commits into
gitgitgadget:mainfrom
dscho:whats-cooking

Conversation

@dscho

@dscho dscho commented Feb 16, 2021

Copy link
Copy Markdown
Member

One of the most confusing aspects for new contributors seems to be the fact that they do not get any status updates, but that they are expected to get those from the regularly-sent "What's cooking" mails.

Let's help, by parsing those, and echoing the feedback in the corresponding open PRs GitGitGadget knows about.

This addresses #152.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
dscho requested a review from webstech February 16, 2021 14:54
Comment thread .vscode/settings.json Resolved
Comment thread lib/mail-archive-helper.ts Resolved
Comment thread lib/mail-archive-helper.ts Resolved
Comment thread lib/mail-archive-helper.ts Outdated
for (const branchName of Object.keys(sousChef.branches)) {
const pullRequestURL = branchNameMap[branchName];
const branchURL =
`https://github.com/gitgitgadget/git/commits/${branchName}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make branchURL a literal string and use ${branchURL}${branchName} in comment? Only one template string to process. Ditto for whatsCookingURL.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I changed it.

The only qualm I have about this is that the result looks awful due to the wrapping. Maybe it is time to wave good-bye to that 80 columns/line rule? I think we could safely extend this to at least 120 or 160, or just not have any maximum at all. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is time to wave good-bye to that 80 columns/line rule? I think we could safely extend this to at least 120 or 160, or just not have any maximum at all. What do you think?

I am okay with 120 for code and maybe longer for strings. Not fond of scrolling right in code.

Comment thread lib/mail-archive-helper.ts Resolved
Comment thread lib/mail-archive-helper.ts Resolved
Comment thread lib/sous-chef.ts Resolved
Comment thread lib/sous-chef.ts Resolved
Comment thread lib/sous-chef.ts Resolved
Comment thread lib/sous-chef.ts Resolved
Comment thread lib/sous-chef.ts Resolved
One aspect of Git's contribution process that often puzzles irregular
contributors is that there seem not to be any updates on their patches,
even if the branch was picked up. The reason for that puzzlement is that
those updates are not sent in-thread, but as part of the "What's
cooking" emails that are sent out roughly twice a week.

With this new code, we can start to address this puzzlement by keeping
contributors in the loop, in particular when the Git maintainer expects
a "reroll" (read: a new iteration of the patch series).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
It is frequently confusing contributors who are new to the project when
they do not hear anything about the status of their contribution for
weeks.

Sometimes, the reason is that they are expected to change something, but
the reminder to do so is only sent out via the What's Cooking mails
(which contributors won't receive unless they subscribe to the fire hose
that is the Git mailing list).

Let's be helpful and mirror that status update back to the PR.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho

dscho commented Feb 22, 2021

Copy link
Copy Markdown
Member Author

I updated this PR. Here is the range-diff:

1:  cd308cc ! 1:  a7b17b0 Add a class designed to process the "What's cooking" emails
    @@ lib/sous-chef.ts (new)
     +export class SousChef {
     +    public readonly mbox: string;
     +    public readonly messageID: string | undefined;
    -+    public readonly branches: {
    -+        [branchName: string]: {
    ++    public readonly branches = new Map<string, {
     +            merged: string | undefined;
     +            sectionName: string;
     +            text: string;
    -+        }
    -+    };
    ++        }>();
     +
     +    public constructor(mbox: string) {
     +        this.mbox = mbox;
    -+        this.branches = {};
     +
    -+        const sections = mbox.split(/^-{10,}\n\[([^\]]+)\]\n/mg)
    ++        const sections = mbox.split(/^-{10,}\n\[([^\]]+)\]\n/mg);
     +        for (let i = 1; i < sections.length; i += 2) {
    -+            const sectionName = sections[i]
    ++            const sectionName = sections[i];
     +
     +            const branches = sections[i + 1].split(/\n\* ([a-z][^]+?)\n\n/m);
     +            for (let j = 1; j < branches.length; j += 2) {
     +                const match = branches[j]
     +                    .match(/([^ ]+).*\n *(\(merged to [^)]+\))?/m);
    -+                if (!match) continue;
    ++                if (!match) {
    ++                    continue
    ++                };
     +
     +                const branchName = match[1];
     +                const merged = match[2];
     +                const text = branches[j + 1]
     +                    .replace(/^ /mg, "").replace(/\s*$/, "");
    -+                this.branches[branchName] = { merged, sectionName, text };
    ++                this.branches.set(branchName, { merged, sectionName, text });
     +            }
     +        }
     +
     +        const messageIDMatch =
    -+            `\n${sections[0]}`.match(/\nMessage-ID: <([^>]+)>/im)
    ++            `\n${sections[0]}`.match(/\nMessage-ID: <([^>]+)>/i)
     +        this.messageID = messageIDMatch?.[1];
     +    }
     +}
    @@ tests/sous-chef.test.ts (new)
     +    const sousChef = new SousChef(mbox.toString());
     +    expect(sousChef.messageID)
     +        .toEqual("xmqqim6zz8x6.fsf@gitster.c.googlers.com");
    -+    const branchInfo = sousChef.branches["js/rebase-i-commit-cleanup-fix"];
    ++    const branchInfo = sousChef.branches.get("js/rebase-i-commit-cleanup-fix");
     +    expect(branchInfo).not.toBeUndefined();
    -+    expect(branchInfo.merged)
    ++    expect(branchInfo?.merged)
     +        .toEqual("(merged to 'next' on 2021-01-31 at 358f562e1f)");
    -+    expect(branchInfo.sectionName).toEqual("Graduated to 'master'");
    ++    expect(branchInfo?.sectionName).toEqual("Graduated to 'master'");
     +    const text =
     +        `When "git rebase -i" processes "fixup" insn, there is no reason to
     +clean up the commit log message, but we did the usual stripspace
     +processing.  This has been corrected.`;
    -+    expect(branchInfo.text).toEqual(text);
    ++    expect(branchInfo?.text).toEqual(text);
     +})
      \ No newline at end of file
2:  7b6bebb ! 2:  f2b10a2 Let contributors know about their What's Cooking status
    @@ Metadata
      ## Commit message ##
         Let contributors know about their What's Cooking status
     
    +    It is frequently confusing contributors who are new to the project when
    +    they do not hear anything about the status of their contribution for
    +    weeks.
    +
    +    Sometimes, the reason is that they are expected to change something, but
    +    the reminder to do so is only sent out via the What's Cooking mails
    +    (which contributors won't receive unless they subscribe to the fire hose
    +    that is the Git mailing list).
    +
    +    Let's be helpful and mirror that status update back to the PR.
    +
         Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
     
      ## lib/mail-archive-helper.ts ##
    @@ lib/mail-archive-helper.ts: export class MailArchiveGitHelper {
     +            if (!options || !options.openPRs) {
     +                return;
     +            }
    -+            const branchNameMap: { [branchName: string]: string } = {};
    ++            /*
    ++             * This map points from branch names in `gitster/git` to their
    ++             * corresponding Pull Request URL.
    ++             */
    ++            const branchNameMap = new Map<string, string>();
     +            for (const pullRequestURL of Object.keys(options.openPRs)) {
     +                if (prFilter && !prFilter(pullRequestURL)) {
     +                    continue;
    @@ lib/mail-archive-helper.ts: export class MailArchiveGitHelper {
     +                const prMeta = await this.gggNotes
     +                    .get<IPatchSeriesMetadata>(pullRequestURL);
     +                if (prMeta && prMeta.branchNameInGitsterGit) {
    -+                    branchNameMap[prMeta.branchNameInGitsterGit] =
    -+                        pullRequestURL;
    ++                    branchNameMap.set(prMeta.branchNameInGitsterGit,
    ++                                      pullRequestURL);
     +                }
     +            }
     +            const sousChef = new SousChef(mbox);
     +            if (!sousChef.messageID) {
     +                throw new Error(`Could not parse Message-ID of ${mbox}`);
     +            }
    -+            const whatsCookingURL = "https://lore.kernel.org/git/"
    -+                + sousChef.messageID;
    ++            const whatsCookingBaseURL = "https://lore.kernel.org/git/";
     +            for (const branchName of Object.keys(sousChef.branches)) {
    -+                const pullRequestURL = branchNameMap[branchName];
    -+                const branchURL =
    -+                    `https://github.com/gitgitgadget/git/commits/${branchName}`;
    -+                const pre = sousChef.branches[branchName].text
    -+                    .replace(/&/g, "&amp;")
    -+                    .replace(/</g, "&lt;").replace(/>/g, "&gt;");
    ++                const pullRequestURL = branchNameMap.get(branchName);
     +                if (pullRequestURL) {
    ++                    const branchBaseURL
    ++                        = "https://github.com/gitgitgadget/git/commits/";
    ++                    const pre = sousChef.branches.get(branchName)?.text
    ++                        .replace(/&/g, "&amp;")
    ++                        .replace(/</g, "&lt;").replace(/>/g, "&gt;");
     +                    const comment = `There was a [status update](${
    -+                        whatsCookingURL}) about the branch [\`${
    ++                        whatsCookingBaseURL}${
    ++                        sousChef.messageID}) about the branch [\`${
     +                        branchName}\`](${
    -+                        branchURL}) on the Git mailing list:\n\n<pre>\n${
    ++                        branchBaseURL}${
    ++                        branchName}) on the Git mailing list:\n\n<pre>\n${
     +                        pre}\n</pre>`;
     +                    console.log(`\n${pullRequestURL}: ${comment}`);
     +                    await this.githubGlue

@dscho
dscho requested a review from webstech February 22, 2021 09:15
@webstech

Copy link
Copy Markdown
Contributor

I did not merge in case you want to do something with comment string wrapping.

@dscho

dscho commented Feb 23, 2021

Copy link
Copy Markdown
Member Author

I did not merge in case you want to do something with comment string wrapping.

No, I like to keep such things separate (unless they're really small, which this one isn't).

@webstech webstech left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@webstech
webstech merged commit 8c08649 into gitgitgadget:main Feb 23, 2021
@dscho
dscho deleted the whats-cooking branch February 23, 2021 17:34
@dscho

dscho commented Mar 8, 2021

Copy link
Copy Markdown
Member Author

Hrm. I don't think this one works as advertised. There has been a "What's cooking" mail on March 3rd, but I do not see any corresponding updates. For example, it contains this section:

* ds/commit-graph-generation-config (2021-02-25) 2 commits
  (merged to 'next' on 2021-03-01 at 926537ea97)
 + commit-graph: use config to specify generation type
 + commit-graph: create local repository pointer

 A new configuration variable has been introduced to allow choosing
 which version of the generation number gets used in the
 commit-graph file.

 Will cook in 'next'.

But the corresponding PR did not receive any comment.

dscho added a commit to dscho/gitgitgadget that referenced this pull request Mar 8, 2021
In the review of gitgitgadget#458,
we decided to go for a `Map` to store the parsed branches (a previous
iteration had used a plain old Javascript object instead).

The one user of this map was not updated accordingly.

This prevented
https://dev.azure.com/gitgitgadget/git/_build/results?buildId=78770 from
handling the "What's cooking" mail properly, even though
https://lore.kernel.org/git/xmqqlfb4k0h8.fsf@gitster.c.googlers.com/ was
properly parsed correctly (in https://lore.kernel.org/git/0, that mail
was added via 3ae7c4db85fed3028585ead06e2da1d8a11316b0).

Let's fix this.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho

dscho commented Mar 8, 2021

Copy link
Copy Markdown
Member Author

@webstech if you're curious how I broke the code that I added in this PR, here is the solution to the riddle: #487.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants