Skip to content

Commit

Permalink
feat: 11번 문제 채점 로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
flydog98 authored and LuizyHub committed Dec 4, 2023
1 parent d6b0430 commit d12d6ec
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/backend/src/quiz-wizard/magic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class Magic {
const command = `docker exec -w /home/quizzer/quiz/ -u quizzer ${container} git branch --list '${branch}'`;
const { stdoutData } = await this.sshService.executeSSHCommand(command);

return stdoutData !== '';
return stdoutData.trim() !== '';
}

async getConfig(container: string, key: string): Promise<string> {
Expand Down Expand Up @@ -99,4 +99,12 @@ export class Magic {

return stdoutData;
}

async getRecentStashPatch(container: string): Promise<string> {
const { stdoutData } = await this.sshService.executeSSHCommand(
`docker exec -u quizzer -w /home/quizzer/quiz ${container} sh -c "git stash show -p"`,
);

return stdoutData;
}
}
29 changes: 29 additions & 0 deletions packages/backend/src/quiz-wizard/quiz-wizard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class QuizWizardService {
8: (containerId: string) => this.checkCondition8(containerId),
9: (containerId: string) => this.checkCondition9(containerId),
10: (containerId: string) => this.checkCondition10(containerId),
11: (containerId: string) => this.checkCondition11(containerId),
12: (containerId: string) => this.checkCondition12(containerId),
13: (containerId: string) => this.checkCondition13(containerId),
15: (containerId: string) => this.checkCondition15(containerId),
Expand Down Expand Up @@ -171,6 +172,34 @@ index e69de29..3b18e51 100644
return true;
}

async checkCondition11(containerId: string): Promise<boolean> {
if (!(await this.magic.isBranchExist(containerId, 'hotfix/fixA'))) {
return false;
}

if (
(await this.magic.getRecentStashPatch(containerId)) !==
`diff --git a/login.js b/login.js
index e69de29..bf5c54f 100644
--- a/login.js
+++ b/login.js
@@ -0,0 +1 @@
+console.log("implementing login")
`
) {
return false;
}

if (
(await this.magic.getTreeHead(containerId, 'hotfix/fixA')) !==
'bebe52f7d1c8440fb4b1af9aa70ad9523d56336b'
) {
return false;
}

return true;
}

async checkCondition12(containerId: string): Promise<boolean> {
if (
(await this.magic.getTreeHead(containerId, 'main')) !==
Expand Down

0 comments on commit d12d6ec

Please sign in to comment.