Compare commits

..

13 Commits

Author SHA1 Message Date
techknowlogick
df941f5c39 Add 1.4.2 changelog (#4115) 2018-06-05 01:45:21 +03:00
David Schneiderbauer
1b10bc0cdf update git vendor (#4059) (#4075)
* update git vendor (#4059)

* fix errors resulting from git vendor update

* fmt
2018-06-04 23:33:42 +03:00
Antoine GIRARD
561f459364 Fix #4081 Check for leading / in base before removing it (#4083) 2018-05-30 11:46:30 -04:00
Jonas Franz
1177a19a5b Use ResolveReference instead of path.Join (#4073)
Signed-off-by: Jonas Franz <info@jonasfranz.software>
2018-05-29 12:12:04 -04:00
Alexey Terentyev
d1954ae4e7 Added deletion of an empty line at the end of file (#4054) (#4074)
Signed-off-by: Alexey Terentyev <axifnx@gmail.com>
2018-05-29 17:42:57 +08:00
Lunny Xiao
7673ca9646 fix attachment ENABLED (#4064) (#4066)
* fix attachment ENABLED

* change wrong name on app.ini.sample
2018-05-29 08:27:44 +08:00
Michael Kuhn
2d0db24083 Fix wiki redirects (#3919) (#4065)
When creating or editing a wiki page, the redirect to the wiki page does
not work because the file name is used instead of the page name.
2018-05-28 11:13:53 -04:00
Morgan Bazalgette
dec663cc0a Don't force due date to current time (#3830) (#4057) 2018-05-27 21:34:33 +03:00
Lunny Xiao
804148294a fix writer cannot read bare repo guide (#4033) (#4039) 2018-05-24 22:44:21 +08:00
Lunny Xiao
910e379265 fix webhook bug of response info is not displayed in UI (#4023) 2018-05-23 11:57:21 +03:00
奶爸
f1720ad133 webhook and hook_task clean up (#4006)
webhook and hook_task clean up
2018-05-22 02:08:21 +03:00
David Schneiderbauer
5f169bfcfd add missing token validation on application settings page (#3976) (#3978) 2018-05-16 23:55:14 +08:00
David Schneiderbauer
50adbb7134 Adjust z-index for floating labels (#3939) (#3950) 2018-05-12 00:36:03 +03:00
26 changed files with 340 additions and 144 deletions

View File

@@ -4,6 +4,21 @@ This changelog goes through all the changes that have been made in each release
without substantial changes to our git log; to see the highlights of what has
been added to each release, please refer to the [blog](https://blog.gitea.io).
## [1.4.2](https://github.com/go-gitea/gitea/releases/tag/v1.4.2) - 2018-06-04
* BUGFIXES
* Adjust z-index for floating labels (#3939) (#3950)
* Add missing token validation on application settings page (#3976) #3978
* Webhook and hook_task clean up (#4006)
* Fix webhook bug of response info is not displayed in UI (#4023)
* Fix writer cannot read bare repo guide (#4033) (#4039)
* Don't force due date to current time (#3830) (#4057)
* Fix wiki redirects (#3919) (#4065)
* Fix attachment ENABLED (#4064) (#4066)
* Added deletion of an empty line at the end of file (#4054) (#4074)
* Use ResolveReference instead of path.Join (#4073)
* Fix #4081 Check for leading / in base before removing it (#4083)
* Respository's home page not updated after first push (#4075)
## [1.4.1](https://github.com/go-gitea/gitea/releases/tag/v1.4.1) - 2018-05-03
* BREAKING
* Add "error" as reserved username (#3882) (#3886)

View File

@@ -403,7 +403,7 @@ ENABLE_FEDERATED_AVATAR = false
[attachment]
; Whether attachments are enabled. Defaults to `true`
ENABLE = true
ENABLED = true
; Path for attachments. Defaults to `data/attachments`
PATH = data/attachments
; One or more allowed types, e.g. image/jpeg|image/png

View File

@@ -14,6 +14,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"strconv"
"strings"
"code.gitea.io/git"
@@ -368,8 +369,15 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D
a := line[beg+2 : middle]
b := line[middle+3:]
if hasQuote {
a = string(git.UnescapeChars([]byte(a[1 : len(a)-1])))
b = string(git.UnescapeChars([]byte(b[1 : len(b)-1])))
var err error
a, err = strconv.Unquote(a)
if err != nil {
return nil, fmt.Errorf("Unquote: %v", err)
}
b, err = strconv.Unquote(b)
if err != nil {
return nil, fmt.Errorf("Unquote: %v", err)
}
}
curFile = &DiffFile{

View File

@@ -31,11 +31,6 @@ type Milestone struct {
ClosedDateUnix util.TimeStamp
}
// BeforeInsert is invoked from XORM before inserting an object of this type.
func (m *Milestone) BeforeInsert() {
m.DeadlineUnix = util.TimeStampNow()
}
// BeforeUpdate is invoked from XORM before updating this object.
func (m *Milestone) BeforeUpdate() {
if m.NumIssues > 0 {

View File

@@ -1822,6 +1822,8 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
&PullRequest{BaseRepoID: repoID},
&RepoUnit{RepoID: repoID},
&RepoRedirect{RedirectRepoID: repoID},
&Webhook{RepoID: repoID},
&HookTask{RepoID: repoID},
); err != nil {
return fmt.Errorf("deleteBeans: %v", err)
}

View File

@@ -437,7 +437,14 @@ func (t *HookTask) AfterLoad() {
t.RequestInfo = &HookRequest{}
if err := json.Unmarshal([]byte(t.RequestContent), t.RequestInfo); err != nil {
log.Error(3, "Unmarshal[%d]: %v", t.ID, err)
log.Error(3, "Unmarshal RequestContent[%d]: %v", t.ID, err)
}
if len(t.ResponseContent) > 0 {
t.ResponseInfo = &HookResponse{}
if err := json.Unmarshal([]byte(t.ResponseContent), t.ResponseInfo); err != nil {
log.Error(3, "Unmarshal ResponseContent[%d]: %v", t.ID, err)
}
}
}
@@ -619,6 +626,10 @@ func (t *HookTask) deliver() {
log.Trace("Hook delivery failed: %s", t.UUID)
}
if err := UpdateHookTask(t); err != nil {
log.Error(4, "UpdateHookTask [%d]: %v", t.ID, err)
}
// Update webhook last delivery status.
w, err := GetWebhookByID(t.HookID)
if err != nil {
@@ -671,10 +682,6 @@ func DeliverHooks() {
// Update hook task status.
for _, t := range tasks {
t.deliver()
if err := UpdateHookTask(t); err != nil {
log.Error(4, "UpdateHookTask [%d]: %v", t.ID, err)
}
}
// Start listening on new hook requests.
@@ -695,10 +702,6 @@ func DeliverHooks() {
}
for _, t := range tasks {
t.deliver()
if err := UpdateHookTask(t); err != nil {
log.Error(4, "UpdateHookTask [%d]: %v", t.ID, err)
continue
}
}
}
}

View File

@@ -182,7 +182,7 @@ func (f *AddKeyForm) Validate(ctx *macaron.Context, errs binding.Errors) binding
// NewAccessTokenForm form for creating access token
type NewAccessTokenForm struct {
Name string `binding:"Required"`
Name string `binding:"Required;MaxSize(255)"`
}
// Validate valideates the fields

View File

@@ -114,16 +114,25 @@ func cutoutVerbosePrefix(prefix string) string {
// URLJoin joins url components, like path.Join, but preserving contents
func URLJoin(base string, elems ...string) string {
u, err := url.Parse(base)
if !strings.HasSuffix(base, "/") {
base += "/"
}
baseURL, err := url.Parse(base)
if err != nil {
log.Error(4, "URLJoin: Invalid base URL %s", base)
return ""
}
joinArgs := make([]string, 0, len(elems)+1)
joinArgs = append(joinArgs, u.Path)
joinArgs = append(joinArgs, elems...)
u.Path = path.Join(joinArgs...)
return u.String()
joinedPath := path.Join(elems...)
argURL, err := url.Parse(joinedPath)
if err != nil {
log.Error(4, "URLJoin: Invalid arg %s", joinedPath)
return ""
}
joinedURL := baseURL.ResolveReference(argURL).String()
if !baseURL.IsAbs() && !strings.HasPrefix(base, "/") {
return joinedURL[1:] // Removing leading '/' if needed
}
return joinedURL
}
// RenderIssueIndexPatternOptions options for RenderIssueIndexPattern function

View File

@@ -83,6 +83,14 @@ func TestURLJoin(t *testing.T) {
"a", "b/c/"),
newTest("a/b/d",
"a/", "b/c/", "/../d/"),
newTest("https://try.gitea.io/a/b/c#d",
"https://try.gitea.io", "a/b", "c#d"),
newTest("/a/b/d",
"/a/", "b/c/", "/../d/"),
newTest("/a/b/c",
"/a", "b/c/"),
newTest("/a/b/c#hash",
"/a", "b/c#hash"),
} {
assert.Equal(t, test.Expected, URLJoin(test.Base, test.Elements...))
}

View File

@@ -956,7 +956,7 @@ func NewContext() {
AttachmentAllowedTypes = strings.Replace(sec.Key("ALLOWED_TYPES").MustString("image/jpeg,image/png,application/zip,application/gzip"), "|", ",", -1)
AttachmentMaxSize = sec.Key("MAX_SIZE").MustInt64(4)
AttachmentMaxFiles = sec.Key("MAX_FILES").MustInt(5)
AttachmentEnabled = sec.Key("ENABLE").MustBool(true)
AttachmentEnabled = sec.Key("ENABLED").MustBool(true)
TimeFormatKey := Cfg.Section("time").Key("FORMAT").MustString("RFC1123")
TimeFormat = map[string]string{

File diff suppressed because one or more lines are too long

View File

@@ -152,6 +152,10 @@ pre, code {
}
}
&.floating.label {
z-index: 10;
}
&.menu,
&.vertical.menu,
&.segment {
@@ -167,6 +171,14 @@ pre, code {
font-size: .92857143rem;
}
&.dropdown .menu>.item>.floating.label {
z-index: 11;
}
&.dropdown .menu .menu>.item>.floating.label {
z-index: 21;
}
.text {
&.red {
color: #d95c5c !important;

View File

@@ -223,6 +223,10 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
var output bytes.Buffer
lines := strings.Split(fileContent, "\n")
//Remove blank line at the end of file
if len(lines) > 0 && lines[len(lines)-1] == "" {
lines = lines[:len(lines)-1]
}
for index, line := range lines {
line = gotemplate.HTMLEscapeString(line)
if index != len(lines)-1 {

View File

@@ -350,7 +350,7 @@ func NewWikiPost(ctx *context.Context, form auth.NewWikiForm) {
return
}
ctx.Redirect(ctx.Repo.RepoLink + "/wiki/" + models.WikiNameToFilename(wikiName))
ctx.Redirect(ctx.Repo.RepoLink + "/wiki/" + models.WikiNameToSubURL(wikiName))
}
// EditWiki render wiki modify page
@@ -391,7 +391,7 @@ func EditWikiPost(ctx *context.Context, form auth.NewWikiForm) {
return
}
ctx.Redirect(ctx.Repo.RepoLink + "/wiki/" + models.WikiNameToFilename(newWikiName))
ctx.Redirect(ctx.Repo.RepoLink + "/wiki/" + models.WikiNameToSubURL(newWikiName))
}
// DeleteWikiPagePost delete wiki page

View File

@@ -5,7 +5,7 @@
<div class="ui grid">
<div class="sixteen wide column content">
{{template "base/alert" .}}
{{if .IsRepositoryAdmin}}
{{if .IsRepositoryWriter}}
<h4 class="ui top attached header">
{{.i18n.Tr "repo.quick_guide"}}
</h4>

38
vendor/code.gitea.io/git/Gopkg.lock generated vendored Normal file
View File

@@ -0,0 +1,38 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
branch = "master"
name = "github.com/Unknwon/com"
packages = ["."]
revision = "7677a1d7c1137cd3dd5ba7a076d0c898a1ef4520"
[[projects]]
name = "github.com/davecgh/go-spew"
packages = ["spew"]
revision = "6d212800a42e8ab5c146b8ace3490ee17e5225f9"
[[projects]]
name = "github.com/mcuadros/go-version"
packages = ["."]
revision = "257f7b9a7d87427c8d7f89469a5958d57f8abd7c"
[[projects]]
name = "github.com/pmezard/go-difflib"
packages = ["difflib"]
revision = "d8ed2627bdf02c080bf22230dbb337003b7aba2d"
[[projects]]
name = "github.com/stretchr/testify"
packages = [
"assert",
"require"
]
revision = "976c720a22c8eb4eb6a0b4348ad85ad12491a506"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "d37e90051cd58dd1f99f808626e82d64eac47f2b2334c6fcb9179bfcf2814622"
solver-name = "gps-cdcl"
solver-version = 1

34
vendor/code.gitea.io/git/Gopkg.toml generated vendored Normal file
View File

@@ -0,0 +1,34 @@
# Gopkg.toml
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true
[[constraint]]
name = "github.com/Unknwon/com"
branch = "master"
[prune]
go-tests = true
unused-packages = true

View File

@@ -18,3 +18,4 @@ Antoine Girard <sapk@sapk.fr> (@sapk)
Jonas Östanbäck <jonas.ostanback@gmail.com> (@cez81)
David Schneiderbauer <dschneiderbauer@gmail.com> (@daviian)
Peter Žeby <morlinest@gmail.com> (@morlinest)
Jonas Franz <info@jonasfranz.software> (@JonasFranzDEV)

10
vendor/code.gitea.io/git/error.go generated vendored
View File

@@ -40,6 +40,16 @@ func (err ErrNotExist) Error() string {
return fmt.Sprintf("object does not exist [id: %s, rel_path: %s]", err.ID, err.RelPath)
}
// ErrBadLink entry.FollowLink error
type ErrBadLink struct {
Name string
Message string
}
func (err ErrBadLink) Error() string {
return fmt.Sprintf("%s: %s", err.Name, err.Message)
}
// ErrUnsupportedVersion error when required git version not matched
type ErrUnsupportedVersion struct {
Required string

81
vendor/code.gitea.io/git/parse.go generated vendored Normal file
View File

@@ -0,0 +1,81 @@
// Copyright 2018 The Gitea 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 git
import (
"bytes"
"fmt"
"strconv"
)
// ParseTreeEntries parses the output of a `git ls-tree` command.
func ParseTreeEntries(data []byte) ([]*TreeEntry, error) {
return parseTreeEntries(data, nil)
}
func parseTreeEntries(data []byte, ptree *Tree) ([]*TreeEntry, error) {
entries := make([]*TreeEntry, 0, 10)
for pos := 0; pos < len(data); {
// expect line to be of the form "<mode> <type> <sha>\t<filename>"
entry := new(TreeEntry)
entry.ptree = ptree
if pos+6 > len(data) {
return nil, fmt.Errorf("Invalid ls-tree output: %s", string(data))
}
switch string(data[pos : pos+6]) {
case "100644":
entry.mode = EntryModeBlob
entry.Type = ObjectBlob
pos += 12 // skip over "100644 blob "
case "100755":
entry.mode = EntryModeExec
entry.Type = ObjectBlob
pos += 12 // skip over "100755 blob "
case "120000":
entry.mode = EntryModeSymlink
entry.Type = ObjectBlob
pos += 12 // skip over "120000 blob "
case "160000":
entry.mode = EntryModeCommit
entry.Type = ObjectCommit
pos += 14 // skip over "160000 object "
case "040000":
entry.mode = EntryModeTree
entry.Type = ObjectTree
pos += 12 // skip over "040000 tree "
default:
return nil, fmt.Errorf("unknown type: %v", string(data[pos:pos+6]))
}
if pos+40 > len(data) {
return nil, fmt.Errorf("Invalid ls-tree output: %s", string(data))
}
id, err := NewIDFromString(string(data[pos : pos+40]))
if err != nil {
return nil, fmt.Errorf("Invalid ls-tree output: %v", err)
}
entry.ID = id
pos += 41 // skip over sha and trailing space
end := pos + bytes.IndexByte(data[pos:], '\n')
if end < pos {
return nil, fmt.Errorf("Invalid ls-tree output: %s", string(data))
}
// In case entry name is surrounded by double quotes(it happens only in git-shell).
if data[pos] == '"' {
entry.name, err = strconv.Unquote(string(data[pos:end]))
if err != nil {
return nil, fmt.Errorf("Invalid ls-tree output: %v", err)
}
} else {
entry.name = string(data[pos:end])
}
pos = end + 1
entries = append(entries, entry)
}
return entries, nil
}

View File

@@ -4,7 +4,21 @@
package git
import "fmt"
// FileBlame return the Blame object of file
func (repo *Repository) FileBlame(revision, path, file string) ([]byte, error) {
return NewCommand("blame", "--root", file).RunInDirBytes(path)
return NewCommand("blame", "--root", "--", file).RunInDirBytes(path)
}
// LineBlame returns the latest commit at the given line
func (repo *Repository) LineBlame(revision, path, file string, line uint) (*Commit, error) {
res, err := NewCommand("blame", fmt.Sprintf("-L %d,%d", line, line), "-p", revision, "--", file).RunInDir(path)
if err != nil {
return nil, err
}
if len(res) < 40 {
return nil, fmt.Errorf("invalid result of blame: %s", res)
}
return repo.GetCommit(string(res[:40]))
}

View File

@@ -9,6 +9,8 @@ import (
"container/list"
"strconv"
"strings"
"github.com/mcuadros/go-version"
)
// GetRefCommitID returns the last commit ID string of given reference (branch or tag).
@@ -274,7 +276,7 @@ func (repo *Repository) CommitsCountBetween(start, end string) (int64, error) {
func (repo *Repository) commitsBefore(id SHA1, limit int) (*list.List, error) {
cmd := NewCommand("log")
if limit > 0 {
cmd.AddArguments("-"+ strconv.Itoa(limit), prettyLogFormat, id.String())
cmd.AddArguments("-"+strconv.Itoa(limit), prettyLogFormat, id.String())
} else {
cmd.AddArguments(prettyLogFormat, id.String())
}
@@ -316,15 +318,35 @@ func (repo *Repository) getCommitsBeforeLimit(id SHA1, num int) (*list.List, err
}
func (repo *Repository) getBranches(commit *Commit, limit int) ([]string, error) {
stdout, err := NewCommand("for-each-ref", "--count="+ strconv.Itoa(limit), "--format=%(refname)", "--contains", commit.ID.String(), BranchPrefix).RunInDir(repo.Path)
if version.Compare(gitVersion, "2.7.0", ">=") {
stdout, err := NewCommand("for-each-ref", "--count="+strconv.Itoa(limit), "--format=%(refname:strip=2)", "--contains", commit.ID.String(), BranchPrefix).RunInDir(repo.Path)
if err != nil {
return nil, err
}
branches := strings.Fields(stdout)
return branches, nil
}
stdout, err := NewCommand("branch", "--contains", commit.ID.String()).RunInDir(repo.Path)
if err != nil {
return nil, err
}
refs := strings.Split(stdout, "\n")
branches := make([]string, len(refs)-1)
for i, ref := range refs[:len(refs)-1] {
branches[i] = strings.TrimPrefix(ref, BranchPrefix)
var max int
if len(refs) > limit {
max = limit
} else {
max = len(refs) - 1
}
branches := make([]string, max)
for i, ref := range refs[:max] {
parts := strings.Fields(ref)
branches[i] = parts[len(parts)-1]
}
return branches, nil
}

29
vendor/code.gitea.io/git/sha1.go generated vendored
View File

@@ -5,6 +5,7 @@
package git
import (
"bytes"
"encoding/hex"
"fmt"
"strings"
@@ -26,43 +27,23 @@ func (id SHA1) Equal(s2 interface{}) bool {
}
return v == id.String()
case []byte:
if len(v) != 20 {
return false
}
for i, v := range v {
if id[i] != v {
return false
}
}
return bytes.Equal(v, id[:])
case SHA1:
for i, v := range v {
if id[i] != v {
return false
}
}
return v == id
default:
return false
}
return true
}
// String returns string (hex) representation of the Oid.
func (id SHA1) String() string {
result := make([]byte, 0, 40)
hexvalues := []byte("0123456789abcdef")
for i := 0; i < 20; i++ {
result = append(result, hexvalues[id[i]>>4])
result = append(result, hexvalues[id[i]&0xf])
}
return string(result)
return hex.EncodeToString(id[:])
}
// MustID always creates a new SHA1 from a [20]byte array with no validation of input.
func MustID(b []byte) SHA1 {
var id SHA1
for i := 0; i < 20; i++ {
id[i] = b[i]
}
copy(id[:], b)
return id
}

83
vendor/code.gitea.io/git/tree.go generated vendored
View File

@@ -5,8 +5,6 @@
package git
import (
"bytes"
"fmt"
"strings"
)
@@ -30,84 +28,6 @@ func NewTree(repo *Repository, id SHA1) *Tree {
}
}
var escapeChar = []byte("\\")
// UnescapeChars reverses escaped characters.
func UnescapeChars(in []byte) []byte {
if bytes.Index(in, escapeChar) == -1 {
return in
}
endIdx := len(in) - 1
isEscape := false
out := make([]byte, 0, endIdx+1)
for i := range in {
if in[i] == '\\' && !isEscape {
isEscape = true
continue
}
isEscape = false
out = append(out, in[i])
}
return out
}
// parseTreeData parses tree information from the (uncompressed) raw
// data from the tree object.
func parseTreeData(tree *Tree, data []byte) ([]*TreeEntry, error) {
entries := make([]*TreeEntry, 0, 10)
l := len(data)
pos := 0
for pos < l {
entry := new(TreeEntry)
entry.ptree = tree
step := 6
switch string(data[pos : pos+step]) {
case "100644":
entry.mode = EntryModeBlob
entry.Type = ObjectBlob
case "100755":
entry.mode = EntryModeExec
entry.Type = ObjectBlob
case "120000":
entry.mode = EntryModeSymlink
entry.Type = ObjectBlob
case "160000":
entry.mode = EntryModeCommit
entry.Type = ObjectCommit
step = 8
case "040000":
entry.mode = EntryModeTree
entry.Type = ObjectTree
default:
return nil, fmt.Errorf("unknown type: %v", string(data[pos:pos+step]))
}
pos += step + 6 // Skip string type of entry type.
step = 40
id, err := NewIDFromString(string(data[pos : pos+step]))
if err != nil {
return nil, err
}
entry.ID = id
pos += step + 1 // Skip half of SHA1.
step = bytes.IndexByte(data[pos:], '\n')
// In case entry name is surrounded by double quotes(it happens only in git-shell).
if data[pos] == '"' {
entry.name = string(UnescapeChars(data[pos+1 : pos+step-1]))
} else {
entry.name = string(data[pos : pos+step])
}
pos += step + 1
entries = append(entries, entry)
}
return entries, nil
}
// SubTree get a sub tree by the sub dir path
func (t *Tree) SubTree(rpath string) (*Tree, error) {
if len(rpath) == 0 {
@@ -142,12 +62,11 @@ func (t *Tree) ListEntries() (Entries, error) {
if t.entriesParsed {
return t.entries, nil
}
t.entriesParsed = true
stdout, err := NewCommand("ls-tree", t.ID.String()).RunInDirBytes(t.repo.Path)
if err != nil {
return nil, err
}
t.entries, err = parseTreeData(t, stdout)
t.entries, err = parseTreeEntries(stdout, t)
return t.entries, err
}

View File

@@ -5,6 +5,7 @@
package git
import (
"io"
"sort"
"strconv"
"strings"
@@ -90,6 +91,45 @@ func (te *TreeEntry) Blob() *Blob {
}
}
// FollowLink returns the entry pointed to by a symlink
func (te *TreeEntry) FollowLink() (*TreeEntry, error) {
if !te.IsLink() {
return nil, ErrBadLink{te.Name(), "not a symlink"}
}
// read the link
r, err := te.Blob().Data()
if err != nil {
return nil, err
}
buf := make([]byte, te.Size())
_, err = io.ReadFull(r, buf)
if err != nil {
return nil, err
}
lnk := string(buf)
t := te.ptree
// traverse up directories
for ; t != nil && strings.HasPrefix(lnk, "../"); lnk = lnk[3:] {
t = t.ptree
}
if t == nil {
return nil, ErrBadLink{te.Name(), "points outside of repo"}
}
target, err := t.GetTreeEntryByPath(lnk)
if err != nil {
if IsErrNotExist(err) {
return nil, ErrBadLink{te.Name(), "broken link"}
}
return nil, err
}
return target, nil
}
// GetSubJumpablePathName return the full path of subdirectory jumpable ( contains only one directory )
func (te *TreeEntry) GetSubJumpablePathName() string {
if te.IsSubModule() || !te.IsDir() {

6
vendor/vendor.json vendored
View File

@@ -3,10 +3,10 @@
"ignore": "test appengine",
"package": [
{
"checksumSHA1": "Gz+a5Qo4PCiB/Gf2f02v8HEAxDM=",
"checksumSHA1": "xwQNnA5geMAdbiBjBABtsjqZZMw=",
"path": "code.gitea.io/git",
"revision": "6798d0f202cdc7187c00a467b586a4bdee27e8c9",
"revisionTime": "2018-01-14T14:37:32Z"
"revision": "31f4b8e8c805438ac6d8914b38accb1d8aaf695e",
"revisionTime": "2018-05-26T05:17:21Z"
},
{
"checksumSHA1": "Qtq0kW+BnpYMOriaoCjMa86WGG8=",