diff options
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/code.gitea.io/git/command.go | 5 | ||||
-rw-r--r-- | vendor/code.gitea.io/git/repo_tree.go | 9 | ||||
-rw-r--r-- | vendor/code.gitea.io/git/tree.go | 14 | ||||
-rw-r--r-- | vendor/code.gitea.io/git/tree_entry.go | 15 |
4 files changed, 37 insertions, 6 deletions
diff --git a/vendor/code.gitea.io/git/command.go b/vendor/code.gitea.io/git/command.go index 8ca99fd6d3..fc48d2871b 100644 --- a/vendor/code.gitea.io/git/command.go +++ b/vendor/code.gitea.io/git/command.go @@ -37,9 +37,12 @@ func (c *Command) String() string { // NewCommand creates and returns a new Git Command based on given command and arguments. func NewCommand(args ...string) *Command { + // Make an explicit copy of GlobalCommandArgs, otherwise append might overwrite it + cargs := make([]string, len(GlobalCommandArgs)) + copy(cargs, GlobalCommandArgs) return &Command{ name: "git", - args: append(GlobalCommandArgs, args...), + args: append(cargs, args...), } } diff --git a/vendor/code.gitea.io/git/repo_tree.go b/vendor/code.gitea.io/git/repo_tree.go index 6e3843f7e5..146b919d7a 100644 --- a/vendor/code.gitea.io/git/repo_tree.go +++ b/vendor/code.gitea.io/git/repo_tree.go @@ -18,6 +18,15 @@ func (repo *Repository) getTree(id SHA1) (*Tree, error) { // GetTree find the tree object in the repository. func (repo *Repository) GetTree(idStr string) (*Tree, error) { + if len(idStr) != 40 { + res, err := NewCommand("rev-parse", idStr).RunInDir(repo.Path) + if err != nil { + return nil, err; + } + if len(res) > 0 { + idStr = res[:len(res)-1] + } + } id, err := NewIDFromString(idStr) if err != nil { return nil, err diff --git a/vendor/code.gitea.io/git/tree.go b/vendor/code.gitea.io/git/tree.go index 4654dac30e..b67bf55840 100644 --- a/vendor/code.gitea.io/git/tree.go +++ b/vendor/code.gitea.io/git/tree.go @@ -70,3 +70,17 @@ func (t *Tree) ListEntries() (Entries, error) { t.entries, err = parseTreeEntries(stdout, t) return t.entries, err } + +// ListEntriesRecursive returns all entries of current tree recursively including all subtrees +func (t *Tree) ListEntriesRecursive() (Entries, error) { + if t.entriesParsed { + return t.entries, nil + } + stdout, err := NewCommand("ls-tree", "-t", "-r", t.ID.String()).RunInDirBytes(t.repo.Path) + + if err != nil { + return nil, err + } + t.entries, err = parseTreeEntries(stdout, t) + return t.entries, err +} diff --git a/vendor/code.gitea.io/git/tree_entry.go b/vendor/code.gitea.io/git/tree_entry.go index 6201eef8fd..ead0d4f5df 100644 --- a/vendor/code.gitea.io/git/tree_entry.go +++ b/vendor/code.gitea.io/git/tree_entry.go @@ -18,15 +18,15 @@ type EntryMode int // one of these. const ( // EntryModeBlob - EntryModeBlob EntryMode = 0100644 + EntryModeBlob EntryMode = 0x0100644 // EntryModeExec - EntryModeExec EntryMode = 0100755 + EntryModeExec EntryMode = 0x0100755 // EntryModeSymlink - EntryModeSymlink EntryMode = 0120000 + EntryModeSymlink EntryMode = 0x0120000 // EntryModeCommit - EntryModeCommit EntryMode = 0160000 + EntryModeCommit EntryMode = 0x0160000 // EntryModeTree - EntryModeTree EntryMode = 0040000 + EntryModeTree EntryMode = 0x0040000 ) // TreeEntry the leaf in the git tree @@ -50,6 +50,11 @@ func (te *TreeEntry) Name() string { return te.name } +// Mode returns the mode of the entry +func (te *TreeEntry) Mode() EntryMode { + return te.mode +} + // Size returns the size of the entry func (te *TreeEntry) Size() int64 { if te.IsDir() { |