Skip to content

[Feature/Git]: Handle remote branch divergence and merge conflicts gracefully #63

Description

@ErebAsh

Problem Statement / Context

The VS Code extension watches for local file saves and stages them in the cloud. However, between the time a user saves a file in VS Code and commits it via their phone, a colleague (or an automated pipeline) may push changes to the same branch on GitHub. Currently, pushing the GitPhone commit will either overwrite the remote changes or result in a PyGithub HTTP 409 Conflict crash, providing no recovery path for the mobile user.

Proposed Solution

Implement a Stale State Detection mechanism. When the user taps "Commit" in Telegram, the backend must verify the target branch's HEAD SHA against the base_sha recorded when the files were originally staged in VS Code.

Technical Implementation Details

  • Update the VS Code extension payload to include the local HEAD SHA when syncing a file change.
  • In github_service.py (commit method), before creating the tree, fetch the current remote branch HEAD SHA.
  • If local_sha != remote_sha, abort the commit and alert the user in Telegram.
  • Provide interactive Telegram buttons:
    • [Force Commit] - Proceeds with the commit (overwriting/creating a new tree).
    • [Create New Branch] - Automatically creates a new branch (e.g., username/patch-1) and commits the staged files there to preserve work.
    • [Abort] - Drops the staged files.

Acceptance Criteria

  • The schema is updated to store base_sha per staging session.
  • A PyGithub conflict is gracefully caught and translated into a human-readable Telegram menu.
  • The user can successfully branch off and commit their work if the original branch diverged.

Impact & Risks

  • Effort: High (Requires modifying extension, backend schema, and bot UX).

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions