Skip to content

[Feature Request] GitHub Push Integration Using REST API (libcurl) #2

@aadityansha06

Description

@aadityansha06

❓ What’s the Feature

Looking for help implementing a new feature in snip:

Allow users to push committed versions/files directly to their GitHub repository using GitHub REST API.

This would allow users to run a command like:

snip push -hello.c -repo "user/repo" -token "ghp_123abc..." -branch "main"

…and have the committed versions pushed directly to GitHub!


🔧 Technical Direction (Suggested)

This feature would likely use:

  • GitHub REST API v3
  • libcurl for sending HTTP requests
    • Use PUT method with appropriate headers
    • Authenticate using a GitHub personal access token (PAT)
    • Construct application/json body for file content, commit message, and branch
  • Base64 encoding of file content (as required by GitHub API)

🧠 Requirements

  • Authenticate using Authorization: token <your_token>
  • Get the latest SHA if the file already exists
  • Construct proper JSON payload like:
{
  "message": "your commit message",
  "content": "base64-encoded content",
  "branch": "main"
}
  • Endpoint to use:
PUT https://api.github.com/repos/{owner}/{repo}/contents/{path}

📋 Example Workflow

  1. User adds and commits file using snip
  2. User runs:
    snip push -hello.c -repo "username/repo" -token "ghp_xxx" -branch "main"
  3. Tool locates the last committed version of hello.c, encodes it in base64
  4. Sends PUT request to:
    https://api.github.com/repos/username/repo/contents/hello.c
    
  5. On success, prints:
    File successfully pushed to GitHub.

🙌 Help Wanted

If you’re comfortable with:

  • libcurl
  • GitHub REST APIs
  • JSON construction and encoding in C

...your contribution would be massively appreciated!

Feel free to comment here or open a PR. I'm happy to collaborate and test the integration!


🏷 Labels

  • enhancement
  • help wanted
  • github-api
  • libcurl
  • feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions