-
Notifications
You must be signed in to change notification settings - Fork 146
Repositories
List repositories that are accessible to the authenticated user.
This includes repositories owned by the authenticated user, repositories where the authenticated user is a collaborator, and repositories that the authenticated user has access to through an organization membership.
GET /user/repos
Status: 200 OK
Content-Type: application/json
[
{
"id": 2,
"owner": {
"id": 1,
"username": "unknwon",
"full_name": "",
"email": "[email protected]",
"avatar_url": "/avatars/1"
},
"full_name": "unknwon/macaron",
"private": false,
"fork": false,
"html_url": "http://localhost:3000/unknwon/macaron",
"clone_url": "http://localhost:3000/unknwon/macaron.git",
"ssh_url": "jiahuachen@localhost:unknwon/macaron.git",
"permissions": {
"admin": true,
"push": true,
"pull": true
}
},
{
"id": 8,
"owner": {
"id": 2,
"username": "org1",
"full_name": "org1",
"email": "[email protected]",
"avatar_url": "/avatars/2"
},
"full_name": "org1/gogs",
"private": false,
"fork": false,
"html_url": "http://localhost:3000/org1/gogs",
"clone_url": "http://localhost:3000/org1/gogs.git",
"ssh_url": "jiahuachen@localhost:org1/gogs.git",
"permissions": {
"admin": true,
"push": true,
"pull": true
}
}
]
Create a new repository for the authenticated user.
POST /user/repos
Create a new repository in this organization. The authenticated user must be a owner of the specified organization.
POST /orgs/:org/repos
Name | Type | Description |
---|---|---|
name | string | Required The name of the repository |
description | string | A short description of the repository |
private | bool | Either true to create a private repository, or false to create a public one. Default is false
|
auto_init | bool | Pass true to create an initial commit with README, .gitignore and LICENSE. Default is false
|
gitignores | string | Desired language .gitignore templates to apply. Use the name of the templates. For example, "Go" or "Go,SublimeText". |
license | string | Desired LICENSE template to apply. Use the name of the template. For example, "Apache v2 License" or "MIT License". |
readme | string | Desired README template to apply. Use the name of the template. Default is Default
|
If you have created file on your corresponding custom/readme/My README
, then use "My README".
Currently, you can use following placeholder for corresponding values of repository:
-
{Name}
: Repository name -
{Description}
: Repository description -
{CloneURL.SSH}
: Repository SSH clone address -
{CloneURL.HTTPS}
: Repository HTTP/HTTPS clone address
{
"name": "Hello-World",
"description": "This is your first repository",
"private": false
}
Status: 201 Created
Content-Type: application/json
{
"id": 27,
"owner": {
"id": 1,
"username": "unknwon",
"full_name": "",
"email": "[email protected]",
"avatar_url": "/avatars/1"
},
"full_name": "unknwon/Hello-World",
"private": false,
"fork": false,
"html_url": "http://localhost:3000/unknwon/Hello-World",
"clone_url": "http://localhost:3000/unknwon/hello-world.git",
"ssh_url": "jiahuachen@localhost:unknwon/hello-world.git",
"permissions": {
"admin": true,
"push": true,
"pull": true
}
}
GET /repos/:username/:reponame/hooks
Status: 200 OK
Content-Type: application/json
[
{
"id": 14,
"type": "gogs",
"events": [
"create",
"push"
],
"active": true,
"config": {
"content_type": "json",
"url": "http://127.0.0.1:3000/unknwon/repo1/settings/hooks/14"
},
"updated_at": "2015-08-29T18:25:52+08:00",
"created_at": "2015-08-27T20:17:36+08:00"
},
{
"id": 15,
"type": "slack",
"events": [
"create",
"push"
],
"active": true,
"config": {
"channel": "#gogs",
"color": "good",
"content_type": "json",
"icon_url": "https://try.gogs.io/img/favicon.png",
"url": "https://hooks.slack.com/services/T03FHQZLC/B09QNJ2CU/n3nFHS3ISw",
"username": "Gogs"
},
"updated_at": "2015-08-29T18:25:55+08:00",
"created_at": "2015-08-28T23:28:09+08:00"
}
]
POST /repos/:username/:reponame/hooks
Name | Type | Description |
---|---|---|
type | string |
Required The type of webhook, either gogs or slack
|
config | object | Required Key/value pairs to provide settings for this hook |
events | array | Determines what events the hook is triggered for. Default: ["push"]
|
active | bool | Determines whether the hook is actually triggered on pushes. Default is false
|
To create a webhook, the following fields are used by the config
:
-
url
: A required string defining the URL to which the payloads will be delivered. -
content_type
: A required string defining the media type used to serialize the payloads. Supported values includejson
andform
. -
secret
: An optional string that’s passed with the HTTP requests body, e.g.{"secret": "xxx"}
.
Here’s how you can create a hook that posts payloads in JSON format:
{
"type": "gogs",
"config": {
"url": "http://gogs.io",
"content_type": "json"
},
"events": [
"create",
"push"
],
"active": true
}
Status: 201 Created
Content-Type: application/json
{
"id": 20,
"type": "gogs",
"config": {
"content_type": "json",
"url": "http://gogs.io"
},
"events": [
"create",
"push"
],
"active": true,
"updated_at": "2015-08-29T11:31:22.453572732+08:00",
"created_at": "2015-08-29T11:31:22.453569275+08:00"
}
PATCH /repos/:username/:reponame/hooks/:id
Name | Type | Description |
---|---|---|
config | object | Required Key/value pairs to provide settings for this hook |
events | array | Determines what events the hook is triggered for. Default: ["push"]
|
active | bool | Determines whether the hook is actually triggered on pushes. Ignore this field to leave it unchanged |
{
"config": {
"url": "http://gogs.io/hook"
},
"events": [
"push"
]
}
Status: 200 OK
Content-Type: application/json
{
"id": 20,
"type": "gogs",
"config": {
"content_type": "json",
"url": "http://gogs.io/hook"
},
"events": [
"push"
],
"active": true,
"updated_at": "2015-08-29T11:45:30.577057789+08:00",
"created_at": "2015-08-29T11:31:22+08:00"
}