-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
❓ 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
- Use
- 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
- User adds and commits file using
snip
- User runs:
snip push -hello.c -repo "username/repo" -token "ghp_xxx" -branch "main"
- Tool locates the last committed version of
hello.c
, encodes it in base64 - Sends PUT request to:
https://api.github.com/repos/username/repo/contents/hello.c
- 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
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed