Skip to content

Commit

Permalink
feat(#49): pdd.ts hardcoded
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed Mar 18, 2024
1 parent 207dd2e commit 4f3df7a
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import {ChatGpt} from "./chat-gpt";
import {Feedback} from "./feedback";
import {Titled} from "./titled";
import {Excluded} from "./excluded";
import {Ranged} from "./ranged";
import {Blob} from "./blob";
import {Puzzled} from "./puzzled";
import {Pdd} from "./pdd";

export let github: {
context: {
Expand Down Expand Up @@ -99,21 +99,9 @@ async function run() {
core.setFailed(reason);
throw new Error(reason);
}
// if (new Puzzled(body).value()) {
// // run pdd.ts
// }
// const puzzle = new Ranged(
// await new Blob(octokit).asText(),
// "150-156"
// ).asText();
// console.log(puzzle);

const puzzle = new Ranged(
await new Blob(octokit).asText(),
"150-156"
).asText();
console.log(puzzle);

if (new Puzzled(body).value()) {
await new Pdd(octokit).run();
}
const openai = core.getInput("openai_token");
if (openai) {
const model = core.getInput("openai_model");
Expand Down
52 changes: 52 additions & 0 deletions src/pdd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2023-2024 Tracehub.git
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

import {Ranged} from "./ranged";
import {Blob} from "./blob";
import {Octokit} from "@octokit/rest";

/**
* PDD routine.
*/
export class Pdd {

/**
* Ctor.
* @param github GitHub
*/
constructor(private readonly github: Octokit) {
}

/**
* Run it.
*/
async run() {
const puzzle = new Ranged(
await new Blob(this.github).asText(), // async -> await
"150-156" // from parsed link
// /https://github.com/tracehubpm/tracehub/blob/8d2aca048e33a5c9d83a49af4246c9ad7fde9998/src/main/java/git/tracehub/tk/TkGitHub.java#L150-L156
).asText();
console.log(puzzle);
}
}
45 changes: 45 additions & 0 deletions src/puzzled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2023-2024 Tracehub.git
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

/**
* Puzzled or not.
*/
export class Puzzled {

/**
* Ctor.
* @param report Bug report
*/
constructor(private readonly report: string) {
}

/**
* Is it puzzled or not.
*/
value(): boolean {
return new RegExp(
"The puzzle `*.+` from #\d+ has to be resolved*.+"
).test(this.report);
}
}

0 comments on commit 4f3df7a

Please sign in to comment.