gogs/internal
ᴜɴᴋɴᴡᴏɴ 5ad2fdcf0b
api: `GET /repos/:owner/:repo/contents/:path` (#5963)
* support API `GET /repos/:owner/:repo/contents/:path`

This PR adds support to #5949:
`GET /repos/:owner/:repo/contents/:path`

Curl:

```bash
curl -H "Authorization: token REDACTED"
http://localhost:3000/api/v1/repos/root/testrepo/contents//master/README.md
-X GET  | jq .
```

Curl  Response:

```bash
{
  "type": "blob",
  "size": 12,
  "name": "README.md",
  "path": "README.md",
  "sha": "70fcb456d436f08462602f26df6fb7e167e7a916",
  "url": "http://localhost:3000/api/v1/repos/root/testrepo/contents/README.md",
  "git_url": "70fcb456d4",
  "html_url": "70fcb456d4",
  "download_url": "http://localhost:3000/api/v1/root/testrepo/raw/README.md",
  "_links": {
    "git": "70fcb456d4",
    "self": "http://localhost:3000/api/v1/repos/root/testrepo/contents/README.md",
    "html": "70fcb456d4"
  },
  "content": "IyB0ZXN0cmVwbwoK"
}

```

* rename - path.go to contents.go

* reorder imports

Co-Authored-By: ᴜɴᴋɴᴡᴏɴ <u@gogs.io>

* rename struct to repoContents and fix field order

Co-Authored-By: ᴜɴᴋɴᴡᴏɴ <u@gogs.io>

* rename variable

Co-Authored-By: ᴜɴᴋɴᴡᴏɴ <u@gogs.io>

* rename GetPathContents to GetContents

Co-Authored-By: ᴜɴᴋɴᴡᴏɴ <u@gogs.io>

* return on server error

Co-Authored-By: ᴜɴᴋɴᴡᴏɴ <u@gogs.io>

* resolve conflicts introduced via git web ui

* make constants as method variables

* handle dir type case last

* fix func and var names

* implement suggested changes in review

* refactor smaller funcs to be part of GetContent

* fix content type check for blob after refactoring

* changes based on suggestions

* read full file, return empty json array

* don't set submoduleURL

* set server err msg to method name

* set target to be blob data for symlinks

* Update contents.go

Co-authored-by: ᴜɴᴋɴᴡᴏɴ <u@gogs.io>
2020-03-05 16:15:38 +08:00
..
assets locale: sync from Crowdin (#5965) 2020-03-04 02:28:13 +08:00
auth conf: overhaul auth and user settings (#5942) 2020-02-27 18:06:38 +08:00
avatar internal: move packages under this directory (#5836) 2019-10-24 01:51:46 -07:00
cmd cmd/serv: improve hookMode handling (#5960) 2020-03-02 22:25:28 +08:00
conf cmd/serv: improve hookMode handling (#5960) 2020-03-02 22:25:28 +08:00
context auth: redirect landing URL with subpath prepended (#5964) 2020-03-04 02:02:12 +08:00
cron conf: overhaul server settings (#5928) 2020-02-22 09:05:26 +08:00
db lint: fix some Golang CI lint issues (#5955) 2020-03-01 14:55:03 +08:00
email lint: fix some Golang CI lint issues (#5955) 2020-03-01 14:55:03 +08:00
form lint: fix some Golang CI lint issues (#5955) 2020-03-01 14:55:03 +08:00
httplib lint: fix some Golang CI lint issues (#5955) 2020-03-01 14:55:03 +08:00
lazyregexp all: use lazyregexp (#5911) 2020-01-29 19:36:57 +08:00
markup conf: overhaul server settings (#5928) 2020-02-22 09:05:26 +08:00
osutil conf: add unit tests (#5954) 2020-02-29 22:24:20 +08:00
pathutil repo/editor: clean up tree path 2020-02-19 23:45:02 +08:00
process log: migrate to unknwon.dev/clog/v2 (#5927) 2020-02-20 02:25:02 +08:00
route api: `GET /repos/:owner/:repo/contents/:path` (#5963) 2020-03-05 16:15:38 +08:00
ssh conf: overhaul server settings (#5928) 2020-02-22 09:05:26 +08:00
sync internal: move packages under this directory (#5836) 2019-10-24 01:51:46 -07:00
template lint: fix some Golang CI lint issues (#5955) 2020-03-01 14:55:03 +08:00
testutil conf: add unit tests (#5954) 2020-02-29 22:24:20 +08:00
tool lint: fix some Golang CI lint issues (#5955) 2020-03-01 14:55:03 +08:00