Skip to content

Conversation

@reddevilmidzy
Copy link
Member

Summary

기존에 구현하였던 리비전 기능에 API를 추가하였습니다.

API

  • POST /problems/init/{problem_id}: 문제 생성 API
    • (생각해보니까 유저가 문제를 생성하려는 시점에는 problem_id를 알 수가 없군요. auto increment 값으로 변경해야 겠네요.)
  • POST /changes/{problem_id}/commit body: {"message": "..."}: 스테이지에 올라온 변경사항을 커밋한다.
    • 성공시 200 리턴 {"commit": ""}
  • GET /changes/{problem_id}/log: 커밋 로그를 가져온다.
    • user, time, path, message, paths 포함
    • ex)
[
    {
        "message": "create message",
        "paths": [
            {
                "path": "tests/e.py",
                "status": "ADDED"
            },
            {
                "path": "tests/tmp.py",
                "status": "ADDED"
            }
        ],
        "time": 1760694085,
        "user": "admin"
    },
    {
        "message": "create message",
        "paths": [
            {
                "path": "solutions/c.py",
                "status": "ADDED"
            }
        ],
        "time": 1760693623,
        "user": "admin"
    }
]
  • GET /changes/{problem_id}/status: 커밋되지 않은 변경사항(스테이징 영역)을 가져온다.
[
    {
        "status": "ADDED",
        "path": "solutions/e.py"
    }
]

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds API endpoints for Git-based revision management features to enable version control for problem files. The implementation exposes existing GitManager functionality through REST APIs.

Key Changes:

  • Added three new API endpoints for Git operations: problem initialization, commit management, and status tracking
  • Refactored GitManager to support stateless operation by accepting problem_id as a parameter
  • Updated tests to reflect API path changes from singular (/solution) to plural (/solutions)

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/lib.rs Added new router configurations for /problems/init and /changes endpoints with GitManager state
src/file_manager/handlers.rs Implemented handler functions for create_problem, commit_changes, get_log, and get_status endpoints
src/file_manager/git.rs Refactored GitManager from stateful (storing problem_id) to stateless design, made structs/methods public, added Serialize traits
src/file_manager/models.rs Added CommitRequest model for commit message payload
src/file_manager/mod.rs Exposed git module contents via pub(crate) use
tests/file_manager/handlers.rs Updated all test cases to use new API paths and added integration tests for new Git endpoints

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant