Skip to content

Commit

Permalink
feat: 18번 문제 채점 로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
flydog98 authored and LuizyHub committed Dec 4, 2023
1 parent 91bd8b1 commit 93503db
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/backend/src/quiz-wizard/magic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,27 @@ export class Magic {

return stdoutData;
}

async isBranchExistRemote(
container: string,
remote: string,
branch: string,
): Promise<boolean> {
const command = `docker exec -u quizzer -w /${remote} ${container} git branch --list '${branch}'`;
const { stdoutData } = await this.sshService.executeSSHCommand(command);

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

async getTreeHeadRemote(
container: string,
remote: string,
branch: string,
): Promise<string> {
const { stdoutData } = await this.sshService.executeSSHCommand(
`docker exec -u quizzer -w /${remote} ${container} sh -c "git cat-file -p \\\$(git rev-parse ${branch}) | grep tree | awk '{print \\\$2}'"`,
);

return stdoutData.trim();
}
}
24 changes: 24 additions & 0 deletions packages/backend/src/quiz-wizard/quiz-wizard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,30 @@ upstream /upstream (push)
);
}

async checkCondition18(containerId: string): Promise<boolean> {
if (
!(await this.magic.isBranchExistRemote(
containerId,
'origin',
'feat/merge-master',
))
) {
return false;
}

if (
(await this.magic.getTreeHeadRemote(
containerId,
'origin',
'feat/merge-master',
)) !== 'd173eb2b7c6888bf77fce84b191a433f36c47a91'
) {
return false;
}

return true;
}

async checkCondition19(containerId: string): Promise<boolean> {
return (
(await this.magic.getAllBranch(containerId)) ===
Expand Down

0 comments on commit 93503db

Please sign in to comment.