Skip to content

Commit 0d8edbc

Browse files
committed
TO-DROP: git revert -m 1 HEAD # Revert "Merge branch 'debug-handle-pr-comment'"
This reverts commit dc65f6da9055c7037b4c17c2f293c4f4c1869907, reversing changes made to ab2016a3906d4076f682195f3e0453e9ddf7a3b3.
1 parent 2cd152b commit 0d8edbc

File tree

6 files changed

+2
-106
lines changed

6 files changed

+2
-106
lines changed

.vscode/launch.json

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,6 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7-
{
8-
"name": "Launch GitHub Action",
9-
"type": "node",
10-
"request": "launch",
11-
"runtimeArgs": [
12-
"--inspect-brk",
13-
// "--nolazy",
14-
],
15-
"args": [
16-
"${workspaceFolder}/handle-pr-comment/index.js"
17-
],
18-
"stopOnEntry": false,
19-
"cwd": "${workspaceFolder}",
20-
"runtimeExecutable": null,
21-
"env": {
22-
"NODE_ENV": "development",
23-
"GITGITGADGET_DRY_RUN": "1",
24-
},
25-
"console": "integratedTerminal",
26-
"sourceMaps": true,
27-
"outFiles": [
28-
"${workspaceFolder}/build/**/*.js",
29-
"${workspaceFolder}/dist/**/*.js",
30-
"${workspaceFolder}/lib/**/*.js"
31-
]
32-
},
337
{
348
"name": "Tests",
359
"type": "node",
@@ -44,6 +18,7 @@
4418
],
4519
"stopOnEntry": false,
4620
"cwd": "${workspaceFolder}",
21+
"preLaunchTask": null,
4722
"runtimeExecutable": null,
4823
"env": {
4924
"NODE_ENV": "development"

lib/ci-helper.ts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,6 @@ export class CIHelper {
5454
}
5555

5656
public constructor(workDir: string = "git.git", config?: IConfig, skipUpdate?: boolean, gggConfigDir = ".") {
57-
if (process.env.GITGITGADGET_DRY_RUN) {
58-
// Avoid letting VS Code's `GIT_ASKPASS` any push succeed
59-
Object.keys(process.env).forEach((key) => {
60-
if (key.startsWith("GIT_") || key.startsWith("VSCODE_")) {
61-
console.warn(`Deleting environment variable ${key}`);
62-
delete process.env[key];
63-
}
64-
});
65-
process.env.GIT_CONFIG_NOSYSTEM = "1";
66-
process.env.GIT_CONFIG_GLOBAL = "does-not-exist";
67-
68-
// Disable any credential helper
69-
process.env.GIT_CONFIG_PARAMETERS = [process.env.GIT_CONFIG_PARAMETERS, "'credential.helper='"]
70-
.filter((e) => e)
71-
.join(" ");
72-
}
73-
7457
this.config = config !== undefined ? setConfig(config) : getConfig();
7558
this.gggConfigDir = gggConfigDir;
7659
this.workDir = workDir;
@@ -146,15 +129,6 @@ export class CIHelper {
146129
// Ignore, for now
147130
}
148131

149-
if (!this.smtpOptions && process.env.GITGITGADGET_DRY_RUN) {
150-
this.smtpOptions = {
151-
smtpUser: "user@example.com",
152-
smtpHost: "smtp.example.com",
153-
smtpPass: "password",
154-
};
155-
console.log("Using debug SMTP options:", this.smtpOptions);
156-
}
157-
158132
// eslint-disable-next-line security/detect-non-literal-fs-filename
159133
if (!fs.existsSync(this.workDir)) await git(["init", "--bare", "--initial-branch", "unused", this.workDir]);
160134
for (const [key, value] of [
@@ -288,9 +262,7 @@ export class CIHelper {
288262
}
289263

290264
public parsePRCommentURLInput(): { owner: string; repo: string; prNumber: number; commentId: number } {
291-
const prCommentUrl =
292-
core.getInput("pr-comment-url") || "https://github.com/gitgitgadget/git/pull/1615#issuecomment-3197439884";
293-
265+
const prCommentUrl = core.getInput("pr-comment-url");
294266
const [, owner, repo, prNumber, commentId] =
295267
prCommentUrl.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)#issuecomment-(\d+)$/) || [];
296268
if (!this.config.repo.owners.includes(owner) || repo !== "git") {

lib/git-notes.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ type TemporaryNoteIndex = {
2020

2121
export class GitNotes {
2222
public async push(url: string, token: string | undefined = undefined): Promise<void> {
23-
if (process.env.GITGITGADGET_DRY_RUN) {
24-
console.log(`Would push '${this.notesRef}' to ${url}`);
25-
return; // debug mode does not actually do anything
26-
}
2723
const auth = !token
2824
? []
2925
: [

lib/github-glue.ts

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ export class GitHubGlue {
7979
const [, short, completedAt] = match;
8080
const url = `https://github.com/${baseOwner}/${this.repo}/commit/${gitGitCommit}`;
8181

82-
if (process.env.GITGITGADGET_DRY_RUN) {
83-
console.log(`Would annotate ${originalCommit}:\n${gitGitCommit} as ${short} at ${completedAt}\n${url}`);
84-
return -1; // debug mode does not actually do anything
85-
}
8682
await this.ensureAuthenticated(repositoryOwner);
8783
const checks = await this.client.rest.checks.create({
8884
completed_at: completedAt,
@@ -181,10 +177,6 @@ export class GitHubGlue {
181177
* @returns the comment ID and the URL to the comment
182178
*/
183179
public async addPRComment(pullRequest: pullRequestKeyInfo, comment: string): Promise<{ id: number; url: string }> {
184-
if (process.env.GITGITGADGET_DRY_RUN) {
185-
console.log(`Would add comment to ${JSON.stringify(pullRequest)}:\n${comment}`);
186-
return { id: -1, url: "" }; // debug mode does not actually do anything
187-
}
188180
const prKey = getPullRequestKey(pullRequest);
189181

190182
await this.ensureAuthenticated(prKey.owner);
@@ -216,10 +208,6 @@ export class GitHubGlue {
216208
comment: string,
217209
line?: number,
218210
): Promise<{ id: number; url: string }> {
219-
if (process.env.GITGITGADGET_DRY_RUN) {
220-
console.log(`Would add comment to ${JSON.stringify(pullRequest)}, commit ${commit}:\n${comment}`);
221-
return { id: -1, url: "" }; // debug mode does not actually do anything
222-
}
223211
const prKey = getPullRequestKey(pullRequest);
224212

225213
await this.ensureAuthenticated(prKey.owner);
@@ -253,10 +241,6 @@ export class GitHubGlue {
253241
id: number,
254242
comment: string,
255243
): Promise<{ id: number; url: string }> {
256-
if (process.env.GITGITGADGET_DRY_RUN) {
257-
console.log(`Would add reply to ${JSON.stringify(pullRequest)}, id ${id}:\n${comment}`);
258-
return { id: -1, url: "" }; // debug mode does not actually do anything
259-
}
260244
const prKey = getPullRequestKey(pullRequest);
261245

262246
await this.ensureAuthenticated(prKey.owner);
@@ -281,10 +265,6 @@ export class GitHubGlue {
281265
* @returns the PR number
282266
*/
283267
public async updatePR(prKey: pullRequestKey, body?: string, title?: string): Promise<number> {
284-
if (process.env.GITGITGADGET_DRY_RUN) {
285-
console.log(`Would add update ${JSON.stringify(prKey)}:\ntitle: ${title}\nbody: ${body}`);
286-
return prKey.pull_number; // debug mode does not actually do anything
287-
}
288268
await this.ensureAuthenticated(prKey.owner);
289269

290270
const result = await this.client.rest.pulls.update({
@@ -297,10 +277,6 @@ export class GitHubGlue {
297277
}
298278

299279
public async addPRLabels(pullRequest: pullRequestKeyInfo, labels: string[]): Promise<string[]> {
300-
if (process.env.GITGITGADGET_DRY_RUN) {
301-
console.log(`Would add labels to ${JSON.stringify(pullRequest)}:\n${labels.join(", ")}`);
302-
return labels; // debug mode does not actually do anything
303-
}
304280
const prKey = getPullRequestKey(pullRequest);
305281

306282
await this.ensureAuthenticated(prKey.owner);
@@ -314,10 +290,6 @@ export class GitHubGlue {
314290
}
315291

316292
public async closePR(pullRequest: pullRequestKeyInfo, viaMergeCommit: string): Promise<number> {
317-
if (process.env.GITGITGADGET_DRY_RUN) {
318-
console.log(`Would add close ${JSON.stringify(pullRequest)}:\n${viaMergeCommit}`);
319-
return -1; // debug mode does not actually do anything
320-
}
321293
const prKey = getPullRequestKey(pullRequest);
322294

323295
await this.ensureAuthenticated(prKey.owner);
@@ -482,16 +454,6 @@ export class GitHubGlue {
482454
* @param login the GitHub login
483455
*/
484456
public async getGitHubUserInfo(login: string): Promise<IGitHubUser> {
485-
if (process.env.GITGITGADGET_DRY_RUN) {
486-
if (login === "dscho")
487-
return {
488-
email: "dscho@me.com",
489-
login,
490-
name: "Ohai!",
491-
type: "user",
492-
};
493-
throw new Error(`Cannot mock getByUsername: ${login}`);
494-
}
495457
// required to get email
496458
await this.ensureAuthenticated(this.authenticated || this.owner);
497459

lib/patch-series.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,6 @@ export class PatchSeries {
144144
options.rangeDiff = rangeDiff;
145145
}
146146

147-
if (process.env.GITGITGADGET_DRY_RUN) {
148-
console.log(`Forcing Patch Series to use dry-run mode`);
149-
options = { ...(options || {}), dryRun: true }; // debug mode does not actually do anything
150-
}
151-
152147
return new PatchSeries(notes, options, project, metadata, rangeDiffRanges, patchCount, coverLetter, senderName);
153148
}
154149

lib/send-mail.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ export function parseMBoxMessageIDAndReferences(parsed: IParsedMBox): { messageI
157157
}
158158

159159
export async function sendMail(mail: IParsedMBox, smtpOptions: ISMTPOptions): Promise<string> {
160-
if (process.env.GITGITGADGET_DRY_RUN) {
161-
console.log(`Would send the email:\n${JSON.stringify(mail, null, 2)}`);
162-
return "<Message-ID>"; // debug mode does not actually do anything
163-
}
164160
const transportOpts: SMTPTransport.Options = {
165161
auth: {
166162
pass: smtpOptions.smtpPass,

0 commit comments

Comments
 (0)