Skip to content

Conversation

Copy link

Copilot AI commented Jan 12, 2026

PR #2 implemented GET endpoints for git-bridge to pull from Overleaf. This completes the implementation by adding the POST endpoint for pushing git changes back to Overleaf projects.

Changes

  • POST /api/v0/docs/:project_id/snapshots - Accepts file changes from git-bridge

    • Version validation: Returns 409 if latestVerId doesn't match current version
    • Async processing: Returns 202 immediately, processes files in background
    • File handling: Downloads from URLs, auto-detects text vs binary, updates/creates/deletes files
    • Postback notifications: POSTs results (upToDate, outOfDate, invalidFiles, error) to git-bridge
  • Security: Path traversal prevention, null byte checks, .git directory blocking

  • Documentation: Updated README.md and USAGE.md with request/response formats and troubleshooting

Implementation

// Request from git-bridge
POST /api/v0/docs/:project_id/snapshots
{
  "latestVerId": 243,
  "files": [
    { "name": "main.tex", "url": "http://..." },  // modified
    { "name": "unchanged.tex" }                    // unchanged
  ],
  "postbackUrl": "http://git-bridge/postback"
}

// Immediate response
202 Accepted { "code": "accepted" }

// Async postback to git-bridge
POST {postbackUrl}
{ "code": "upToDate", "latestVerId": 244 }

Uses existing EditorController APIs (upsertDocWithPath, upsertFileWithPath, deleteEntityWithPath) for consistency with other project update paths.

Original prompt

#2 你虽然已经实现了git pull也就是读取数据的时候的逻辑,但是你还需要实现 Pushing a Project to WriteLaTeX Post 的逻辑 继续仔细阅读代码 然后帮我实现完所有的完整功能


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 7 commits December 25, 2025 11:23
Co-authored-by: Musicminion <84625273+Musicminion@users.noreply.github.com>
Co-authored-by: Musicminion <84625273+Musicminion@users.noreply.github.com>
…ndling

Co-authored-by: Musicminion <84625273+Musicminion@users.noreply.github.com>
Co-authored-by: Musicminion <84625273+Musicminion@users.noreply.github.com>
Co-authored-by: Musicminion <84625273+Musicminion@users.noreply.github.com>
Copilot AI and others added 4 commits January 12, 2026 11:51
…idge push

- Add version validation to check latestVerId matches current version
- Implement file download from URLs provided by git-bridge
- Implement project update logic (add/update/delete files)
- Implement postback mechanism to notify git-bridge of results
- Add proper error handling for various failure cases (out of date, invalid files, errors)
- Process push asynchronously after sending 202 Accepted response

Co-authored-by: Musicminion <84625273+Musicminion@users.noreply.github.com>
- Mark POST endpoint as fully implemented in README.md
- Add detailed request/response examples in USAGE.md
- Document async processing and postback mechanism
- Add troubleshooting guide for common issues
- Update error handling documentation

Co-authored-by: Musicminion <84625273+Musicminion@users.noreply.github.com>
- Use strict equality (===) for null comparison
- Use Path.join() for better cross-platform compatibility
- Add clarifying comment about gitBridgeUserId configuration
- Remove completed POST endpoint from Next Steps in USAGE.md

Co-authored-by: Musicminion <84625273+Musicminion@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement pushing a project to WriteLaTeX Post Implement Git Bridge API v0 POST endpoint for bidirectional sync Jan 12, 2026
Copilot AI requested a review from Musicminion January 12, 2026 11:59
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.

2 participants