<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[283743] trunk/Tools</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/283743">283743</a></dd>
<dt>Author</dt> <dd>jbedard@apple.com</dd>
<dt>Date</dt> <dd>2021-10-07 14:22:39 -0700 (Thu, 07 Oct 2021)</dd>
</dl>
<h3>Log Message</h3>
<pre>[WebKitBot] Land local changes on production host
https://bugs.webkit.org/show_bug.cgi?id=231388
<rdar://problem/83996428>
Reviewed by Yusuke Suzuki.
* WebKitBot/src/Commit.mjs: Add Slack ID integration.
* WebKitBot/src/Contributors.mjs: Ditto.
* WebKitBot/src/Utility.mjs:
* WebKitBot/src/WebKitBot.mjs: Add "hi" and "yt" commands.
* WebKitBot/src/index.mjs:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWebKitBotsrcCommitmjs">trunk/Tools/WebKitBot/src/Commit.mjs</a></li>
<li><a href="#trunkToolsWebKitBotsrcContributorsmjs">trunk/Tools/WebKitBot/src/Contributors.mjs</a></li>
<li><a href="#trunkToolsWebKitBotsrcUtilitymjs">trunk/Tools/WebKitBot/src/Utility.mjs</a></li>
<li><a href="#trunkToolsWebKitBotsrcWebKitBotmjs">trunk/Tools/WebKitBot/src/WebKitBot.mjs</a></li>
<li><a href="#trunkToolsWebKitBotsrcindexmjs">trunk/Tools/WebKitBot/src/index.mjs</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (283742 => 283743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog 2021-10-07 21:08:11 UTC (rev 283742)
+++ trunk/Tools/ChangeLog 2021-10-07 21:22:39 UTC (rev 283743)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2021-10-07 Jonathan Bedard <jbedard@apple.com>
+
+ [WebKitBot] Land local changes on production host
+ https://bugs.webkit.org/show_bug.cgi?id=231388
+ <rdar://problem/83996428>
+
+ Reviewed by Yusuke Suzuki.
+
+ * WebKitBot/src/Commit.mjs: Add Slack ID integration.
+ * WebKitBot/src/Contributors.mjs: Ditto.
+ * WebKitBot/src/Utility.mjs:
+ * WebKitBot/src/WebKitBot.mjs: Add "hi" and "yt" commands.
+ * WebKitBot/src/index.mjs:
+
</ins><span class="cx"> 2021-10-07 Michael Catanzaro <mcatanzaro@gnome.org>
</span><span class="cx">
</span><span class="cx"> Misc compiler warning fixes, October 2021
</span></span></pre></div>
<a id="trunkToolsWebKitBotsrcCommitmjs"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitBot/src/Commit.mjs (283742 => 283743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitBot/src/Commit.mjs 2021-10-07 21:08:11 UTC (rev 283742)
+++ trunk/Tools/WebKitBot/src/Commit.mjs 2021-10-07 21:22:39 UTC (rev 283743)
</span><span class="lines">@@ -78,8 +78,12 @@
</span><span class="cx"> this._author = this._email;
</span><span class="cx"> if (this._email) {
</span><span class="cx"> let entry = contributors.queryWithEmail(this._email);
</span><del>- if (entry && entry.nicks && entry.nicks[0])
- this._author = `${entry.name} (@${entry.nicks[0]})`;
</del><ins>+ if (entry) {
+ if (entry.nicks && entry.nicks[0])
+ this._author = `${entry.name} (@${entry.nicks[0]})`;
+ if (entry.slackId)
+ this._authorSlackId = entry.slackId;
+ }
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> if (this._revert) {
</span><span class="lines">@@ -107,6 +111,7 @@
</span><span class="cx"> get radar() { return this._radar; }
</span><span class="cx"> get title() { return this._title; }
</span><span class="cx"> get author() { return this._author; }
</span><ins>+ get authorSlackId() { return this._authorSlackId; }
</ins><span class="cx"> get url() { return this._url; }
</span><span class="cx">
</span><span class="cx"> message()
</span><span class="lines">@@ -113,7 +118,10 @@
</span><span class="cx"> {
</span><span class="cx"> let results = [];
</span><span class="cx"> results.push(escapeForSlackText(`${this._title}`));
</span><del>- results.push(escapeForSlackText(`${this._url} by ${this._author}`));
</del><ins>+ if (!this._authorSlackId)
+ results.push(escapeForSlackText(`${this._url} by ${this._author}`));
+ else
+ results.push(`${escapeForSlackText(this._url)} by <@${this._authorSlackId}>`);
</ins><span class="cx"> let urls = [];
</span><span class="cx"> if (this._bugzilla !== null)
</span><span class="cx"> urls.push(escapeForSlackText(`https://webkit.org/b/${this._bugzilla}`));
</span></span></pre></div>
<a id="trunkToolsWebKitBotsrcContributorsmjs"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitBot/src/Contributors.mjs (283742 => 283743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitBot/src/Contributors.mjs 2021-10-07 21:08:11 UTC (rev 283742)
+++ trunk/Tools/WebKitBot/src/Contributors.mjs 2021-10-07 21:22:39 UTC (rev 283743)
</span><span class="lines">@@ -49,4 +49,13 @@
</span><span class="cx"> {
</span><span class="cx"> return this.emails.get(email);
</span><span class="cx"> }
</span><ins>+
+ queryWithSlackId(slackId)
+ {
+ for (let entry of this.emails.values()) {
+ if (entry.slackId === slackId)
+ return entry;
+ }
+ return null;
+ }
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsWebKitBotsrcUtilitymjs"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitBot/src/Utility.mjs (283742 => 283743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitBot/src/Utility.mjs 2021-10-07 21:08:11 UTC (rev 283742)
+++ trunk/Tools/WebKitBot/src/Utility.mjs 2021-10-07 21:22:39 UTC (rev 283743)
</span><span class="lines">@@ -31,11 +31,9 @@
</span><span class="cx"> return text.replace("&", "&").replace("<", "<").replace(">", ">");
</span><span class="cx"> }
</span><span class="cx">
</span><del>-const DEBUG = false;
-
</del><span class="cx"> export function dataLogLn(message)
</span><span class="cx"> {
</span><del>- if (DEBUG)
</del><ins>+ if (process.env.DEBUG)
</ins><span class="cx"> console.log(message);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsWebKitBotsrcWebKitBotmjs"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitBot/src/WebKitBot.mjs (283742 => 283743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitBot/src/WebKitBot.mjs 2021-10-07 21:08:11 UTC (rev 283742)
+++ trunk/Tools/WebKitBot/src/WebKitBot.mjs 2021-10-07 21:22:39 UTC (rev 283743)
</span><span class="lines">@@ -23,6 +23,7 @@
</span><span class="cx"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><ins>+import {stat} from "fs";
</ins><span class="cx"> import path from "path";
</span><span class="cx"> import util from "util";
</span><span class="cx"> import {execFile, spawn} from "child_process";
</span><span class="lines">@@ -30,12 +31,12 @@
</span><span class="cx"> import AsyncTaskQueue from "./AsyncTaskQueue.mjs";
</span><span class="cx"> import {dataLogLn, escapeForSlackText, isASCII, rootDirectoryOfWebKit} from "./Utility.mjs";
</span><span class="cx">
</span><del>-const webkitPatchPath = path.resolve(rootDirectoryOfWebKit(), "Tools", "Scripts", "webkit-patch");
</del><span class="cx"> const defaultTaskLimit = 10;
</span><span class="cx"> const defaultPullPeriod = 60 * 1000 * 60;
</span><span class="cx"> const defaultTimeoutForRevert = 60 * 1000 * 10;
</span><span class="cx">
</span><span class="cx"> const execFileAsync = util.promisify(execFile);
</span><ins>+const statAsync = util.promisify(stat);
</ins><span class="cx">
</span><span class="cx"> function parseBugId(string)
</span><span class="cx"> {
</span><span class="lines">@@ -173,7 +174,18 @@
</span><span class="cx"> usage: "`status`",
</span><span class="cx"> operation: this.statusCommand.bind(this),
</span><span class="cx"> });
</span><ins>+ this._commands.set("hi", {
+ description: "Responds with hi.",
+ usage: "`hi`",
+ operation: this.hiCommand.bind(this),
+ });
+ this._commands.set("yt?", {
+ description: "Responds with yes.",
+ usage: "`yt?`",
+ operation: this.youThereCommand.bind(this),
+ });
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> this._rtm = new SlackRTMAPI.RTMClient(process.env.SLACK_TOKEN);
</span><span class="cx"> this._rtm.on("message", async (event) => {
</span><span class="cx"> if (event.type !== "message")
</span><span class="lines">@@ -230,9 +242,54 @@
</span><span class="cx"> });
</span><span class="cx"> } catch (error) {
</span><span class="cx"> console.error(error);
</span><ins>+ let stderr = error.stderr;
+ console.error("STDERR ", stderr);
+ if (typeof stderr === "string") {
+ {
+ let index = stderr.indexOf("Failed to apply reverse diff for revision");
+ if (index !== -1) {
+ let lines = stderr.slice(index).split("\n");
+ lines.shift();
+ let files = [];
+ for (let line of lines) {
+ try {
+ await statAsync(path.join(process.env.webkitWorkingDirectory, line));
+ files.push(line);
+ } catch {
+ // THis is not a file.
+ break;
+ }
+ }
+ if (files.length !== 0) {
+ await this._web.chat.postMessage({
+ channel: event.channel,
+ text: `<@${event.user}> Failed to create revert patch because of the following conflicts:
+\`\`\`
+${escapeForSlackText(files.join("\n"))}\`\`\``,
+ });
+ return;
+ }
+ }
+ }
+ {
+ let index = stderr.indexOf("You are not authorized to access bug");
+ if (index !== -1) {
+ let line = stderr.slice(index).split("\n")[0].trim();
+ let matched = /#(\d+)/.match(line);
+ await this._web.chat.postMessage({
+ channel: event.channel,
+ text: `<@${event.user}> Failed to create revert patch. Please ensure commit-queue@webkit.org is authorized to access ${matched ? ("bug " + escapeForSlackText(matched[1])) : "the bug"}.`
+ });
+ return;
+ }
+
+ }
+ }
</ins><span class="cx"> await this._web.chat.postMessage({
</span><span class="cx"> channel: event.channel,
</span><del>- text: `<@${event.user}> Failed to create revert patch.`,
</del><ins>+ text: `<@${event.user}> Failed to create revert patch.` + (stderr ? `
+\`\`\`
+${escapeForSlackText(stderr)}\`\`\`` : ""),
</ins><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx"> return;
</span><span class="lines">@@ -326,10 +383,26 @@
</span><span class="cx"> {
</span><span class="cx"> await this._web.chat.postMessage({
</span><span class="cx"> channel: event.channel,
</span><del>- text: `<@${event.user}> ${escapeForSlackText(this._taskQueue.length)} requests in queue.`,
</del><ins>+ text: `<@${event.user}> ${escapeForSlackText(String(this._taskQueue.length))} requests in queue.`,
</ins><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ async hiCommand(event, command, args)
+ {
+ await this._web.chat.postMessage({
+ channel: event.channel,
+ text: `Hi <@${event.user}>!`,
+ });
+ }
+
+ async youThereCommand(event, command, args)
+ {
+ await this._web.chat.postMessage({
+ channel: event.channel,
+ text: `<@${event.user}> yes`,
+ });
+ }
+
</ins><span class="cx"> async unknownCommand(event, command, args)
</span><span class="cx"> {
</span><span class="cx"> dataLogLn("Unknown command: ", command);
</span><span class="lines">@@ -365,7 +438,7 @@
</span><span class="cx"> await this.execInWebKitDirectorySimple("git", ["clean", "-df"]);
</span><span class="cx">
</span><span class="cx"> dataLogLn("3. Pulling");
</span><del>- await this.execInWebKitDirectorySimple("git", ["pull", "origin", "master"]);
</del><ins>+ await this.execInWebKitDirectorySimple("git", ["pull"]);
</ins><span class="cx">
</span><span class="cx"> dataLogLn("4. Fetching");
</span><span class="cx"> await this.execInWebKitDirectorySimple("git", ["svn", "fetch"]);
</span><span class="lines">@@ -389,6 +462,7 @@
</span><span class="cx"> dataLogLn("5. Creating revert patch ", revisions, reason);
</span><span class="cx"> let results;
</span><span class="cx"> try {
</span><ins>+ const webkitPatchPath = path.resolve("BotWebKit", "Tools", "Scripts", "webkit-patch");
</ins><span class="cx"> results = await execFileAsync(webkitPatchPath, [
</span><span class="cx"> "create-revert",
</span><span class="cx"> "--force-clean",
</span><span class="lines">@@ -412,7 +486,9 @@
</span><span class="cx"> });
</span><span class="cx"> } catch (error) {
</span><span class="cx"> dataLogLn(error);
</span><del>- throw new Error("Revert command failed");
</del><ins>+ let newError = new Error("Revert command failed");
+ newError.stderr = error.stderr;
+ throw newError;
</ins><span class="cx"> }
</span><span class="cx"> let {stdout, stderr} = results;
</span><span class="cx"> dataLogLn(stdout);
</span></span></pre></div>
<a id="trunkToolsWebKitBotsrcindexmjs"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitBot/src/index.mjs (283742 => 283743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitBot/src/index.mjs 2021-10-07 21:08:11 UTC (rev 283742)
+++ trunk/Tools/WebKitBot/src/index.mjs 2021-10-07 21:22:39 UTC (rev 283743)
</span><span class="lines">@@ -25,7 +25,6 @@
</span><span class="cx">
</span><span class="cx"> import dotenv from "dotenv";
</span><span class="cx"> import storage from "node-persist";
</span><del>-import WKR from "./WKR.mjs";
</del><span class="cx"> import WebKitBot from "./WebKitBot.mjs";
</span><span class="cx"> import SlackWebAPI from "@slack/web-api";
</span><span class="cx">
</span><span class="lines">@@ -39,7 +38,6 @@
</span><span class="cx"> let webClient = new SlackWebAPI.WebClient(process.env.SLACK_TOKEN);
</span><span class="cx"> let auth = await webClient.auth.test();
</span><span class="cx">
</span><del>- WKR.main(webClient, auth);
</del><span class="cx"> WebKitBot.main(webClient, auth);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>