-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Repo on Fly.io Gogs instance #9
Comments
Creating a new repo via curl -X POST -H "Content-Type: application/json" -d '{"name": "created-by-curl", "description": "This is your first repository", "private": false}' 'https://gogs-server.fly.dev/api/v1/org/myorg/repos?token=yourtoken' response: {
"id": 5,
"owner": {
"id": 2,
"username": "myorg",
"login": "myorg",
"full_name": "",
"email": "",
"avatar_url": "https://gogs-server.fly.dev/avatars/2"
},
"name": "created-by-curl",
"full_name": "myorg/created-by-curl",
"description": "This is your first repository",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 0,
"html_url": "https://gogs-server.fly.dev/myorg/created-by-curl",
"ssh_url": "ssh://[email protected]:10022/myorg/created-by-curl.git",
"clone_url": "https://gogs-server.fly.dev/myorg/created-by-curl.git",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 0,
"open_issues_count": 0,
"default_branch": "",
"created_at": "0001-01-01T00:00:00Z",
"updated_at": "0001-01-01T00:00:00Z",
"permissions": {
"admin": true,
"push": true,
"pull": true
}
} This means it will work via |
I've setup all the code to make REST API Requests from Elixir using But getting a %HTTPoison.Response{
body: "[{\"classification\":\"ContentTypeError\",\"message\":\"Unsupported Content-Type\"}]",
headers: [
{"content-type", "application/json; charset=utf-8"},
{"set-cookie", "lang=en-US; Path=/; Max-Age=2147483647"},
{"set-cookie", "i_like_gogs=ba89f24ea6c11533; Path=/; HttpOnly"},
{"set-cookie",
"_csrf=xOXKySlsS26hdUvN1acemGQ5aOQ6MTY1MTQ4NzkyMzg5MTUwMDYzNA; Path=/; Domain=gogs-server.fly.dev; Expires=Tue, 03 May 2022 10:38:43 GMT; HttpOnly; Secure"},
{"x-content-type-options", "nosniff"},
{"x-frame-options", "DENY"},
{"date", "Mon, 02 May 2022 10:38:43 GMT"},
{"content-length", "76"},
{"server", "Fly/f2e6d63f (2022-04-27)"},
{"via", "1.1 fly.io"},
{"fly-request-id", "01G225KT6TNN28MXJX3K40V18P-lhr"}
],
request: %HTTPoison.Request{
body: "{\"name\":\"test-repo6\",\"private\":false}",
headers: [
{"Authorization", "token supersecret"}
],
method: :post,
options: [],
params: %{},
url: "https://gogs-server.fly.dev/api/v1/org/myorg/repos"
},
request_url: "https://gogs-server.fly.dev/api/v1/org/myorg/repos",
status_code: 415
}
{:ok,
[
%{
"classification" => "ContentTypeError",
"message" => "Unsupported Content-Type"
}
]} Did a bit of goggling ... 🔍 headers: {'Content-Type': 'application/json'} And now our {:ok,
%{
clone_url: "https://gogs-server.fly.dev/myorg/test-repo7.git",
created_at: "0001-01-01T00:00:00Z",
default_branch: "",
description: "",
empty: false,
fork: false,
forks_count: 0,
full_name: "myorg/test-repo7",
html_url: "https://gogs-server.fly.dev/myorg/test-repo7",
id: 6,
mirror: false,
name: "test-repo7",
open_issues_count: 0,
owner: %{
avatar_url: "https://gogs-server.fly.dev/avatars/2",
email: "",
full_name: "",
id: 2,
login: "myorg",
username: "myorg"
},
parent: nil,
permissions: %{admin: true, pull: true, push: true},
private: false,
size: 0,
ssh_url: "ssh://[email protected]:10022/myorg/test-repo7.git",
stars_count: 0,
updated_at: "0001-01-01T00:00:00Z",
watchers_count: 0,
website: ""
}} https://gogs-server.fly.dev/myorg/test-repo7
|
The test & TestDouble code is 4x the code for the actual implementation. 🙄 |
Ref: Lines 56 to 74 in ec08eb4
|
The first step (after creating an
Org
#8 ...) in using Gogs as a Backup for GitHub is to create a Repository!Reading the API: https://github.com/gogs/docs-api/tree/master/Repositories#create
It appears this should be straightforward:
Todo
Gogs.remote_repo_create/3
Test Double
that returns the desired payload when invoked during testing.The text was updated successfully, but these errors were encountered: