aboutsummaryrefslogtreecommitdiff
path: root/routers/api/v1/repo/file.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-06-11 00:34:14 -0400
committerUnknwon <u@gogs.io>2017-06-11 00:34:14 -0400
commit4400d2fdd933204044aeb18ce7d8613c53aa87c0 (patch)
tree841e91d5294c49b7335170fbc4b9ff79e882f91a /routers/api/v1/repo/file.go
parent6197a7639a88f7fb0fee8927e1d501504ae770ff (diff)
Refactoring: rename package routers -> routes
Diffstat (limited to 'routers/api/v1/repo/file.go')
-rw-r--r--routers/api/v1/repo/file.go72
1 files changed, 0 insertions, 72 deletions
diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go
deleted file mode 100644
index df6a4857..00000000
--- a/routers/api/v1/repo/file.go
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2014 The Gogs Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-package repo
-
-import (
- "github.com/gogits/git-module"
-
- "github.com/gogits/gogs/models"
- "github.com/gogits/gogs/pkg/context"
- "github.com/gogits/gogs/routers/repo"
-)
-
-// https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-raw-content
-func GetRawFile(c *context.APIContext) {
- if !c.Repo.HasAccess() {
- c.Status(404)
- return
- }
-
- if c.Repo.Repository.IsBare {
- c.Status(404)
- return
- }
-
- blob, err := c.Repo.Commit.GetBlobByPath(c.Repo.TreePath)
- if err != nil {
- if git.IsErrNotExist(err) {
- c.Status(404)
- } else {
- c.Error(500, "GetBlobByPath", err)
- }
- return
- }
- if err = repo.ServeBlob(c.Context, blob); err != nil {
- c.Error(500, "ServeBlob", err)
- }
-}
-
-// https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-archive
-func GetArchive(c *context.APIContext) {
- repoPath := models.RepoPath(c.Params(":username"), c.Params(":reponame"))
- gitRepo, err := git.OpenRepository(repoPath)
- if err != nil {
- c.Error(500, "OpenRepository", err)
- return
- }
- c.Repo.GitRepo = gitRepo
-
- repo.Download(c.Context)
-}
-
-func GetEditorconfig(c *context.APIContext) {
- ec, err := c.Repo.GetEditorconfig()
- if err != nil {
- if git.IsErrNotExist(err) {
- c.Error(404, "GetEditorconfig", err)
- } else {
- c.Error(500, "GetEditorconfig", err)
- }
- return
- }
-
- fileName := c.Params("filename")
- def := ec.GetDefinitionForFilename(fileName)
- if def == nil {
- c.Error(404, "GetDefinitionForFilename", err)
- return
- }
- c.JSON(200, def)
-}