summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
Diffstat (limited to 'vendor')
-rw-r--r--vendor/code.gitea.io/git/LICENSE20
-rw-r--r--vendor/code.gitea.io/git/blob.go73
-rw-r--r--vendor/code.gitea.io/git/cache.go11
-rw-r--r--vendor/code.gitea.io/git/command.go137
-rw-r--r--vendor/code.gitea.io/git/commit.go349
-rw-r--r--vendor/code.gitea.io/git/commit_archive.go37
-rw-r--r--vendor/code.gitea.io/git/commit_info.go329
-rw-r--r--vendor/code.gitea.io/git/doc.go5
-rw-r--r--vendor/code.gitea.io/git/error.go66
-rw-r--r--vendor/code.gitea.io/git/git.go91
-rw-r--r--vendor/code.gitea.io/git/hook.go126
-rw-r--r--vendor/code.gitea.io/git/parse.go81
-rw-r--r--vendor/code.gitea.io/git/ref.go18
-rw-r--r--vendor/code.gitea.io/git/repo.go287
-rw-r--r--vendor/code.gitea.io/git/repo_blame.go24
-rw-r--r--vendor/code.gitea.io/git/repo_blob.go30
-rw-r--r--vendor/code.gitea.io/git/repo_branch.go134
-rw-r--r--vendor/code.gitea.io/git/repo_commit.go388
-rw-r--r--vendor/code.gitea.io/git/repo_hook.go15
-rw-r--r--vendor/code.gitea.io/git/repo_object.go19
-rw-r--r--vendor/code.gitea.io/git/repo_pull.go89
-rw-r--r--vendor/code.gitea.io/git/repo_ref.go51
-rw-r--r--vendor/code.gitea.io/git/repo_tag.go149
-rw-r--r--vendor/code.gitea.io/git/repo_tree.go35
-rw-r--r--vendor/code.gitea.io/git/sha1.go76
-rw-r--r--vendor/code.gitea.io/git/signature.go58
-rw-r--r--vendor/code.gitea.io/git/submodule.go87
-rw-r--r--vendor/code.gitea.io/git/tag.go89
-rw-r--r--vendor/code.gitea.io/git/tree.go98
-rw-r--r--vendor/code.gitea.io/git/tree_blob.go59
-rw-r--r--vendor/code.gitea.io/git/tree_entry.go205
-rw-r--r--vendor/code.gitea.io/git/utils.go96
-rw-r--r--vendor/github.com/stretchr/testify/require/doc.go28
-rw-r--r--vendor/github.com/stretchr/testify/require/forward_requirements.go16
-rw-r--r--vendor/github.com/stretchr/testify/require/require.go867
-rw-r--r--vendor/github.com/stretchr/testify/require/require_forward.go687
-rw-r--r--vendor/github.com/stretchr/testify/require/requirements.go9
37 files changed, 1607 insertions, 3332 deletions
diff --git a/vendor/code.gitea.io/git/LICENSE b/vendor/code.gitea.io/git/LICENSE
deleted file mode 100644
index 10aeba46bc..0000000000
--- a/vendor/code.gitea.io/git/LICENSE
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright (c) 2016 The Gitea Authors
-Copyright (c) 2014 The Gogs Authors
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/vendor/code.gitea.io/git/blob.go b/vendor/code.gitea.io/git/blob.go
deleted file mode 100644
index a6e392eeb5..0000000000
--- a/vendor/code.gitea.io/git/blob.go
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "bytes"
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "os/exec"
-)
-
-// Blob represents a Git object.
-type Blob struct {
- repo *Repository
- *TreeEntry
-}
-
-// Data gets content of blob all at once and wrap it as io.Reader.
-// This can be very slow and memory consuming for huge content.
-func (b *Blob) Data() (io.Reader, error) {
- stdout := new(bytes.Buffer)
- stderr := new(bytes.Buffer)
-
- // Preallocate memory to save ~50% memory usage on big files.
- stdout.Grow(int(b.Size() + 2048))
-
- if err := b.DataPipeline(stdout, stderr); err != nil {
- return nil, concatenateError(err, stderr.String())
- }
- return stdout, nil
-}
-
-// DataPipeline gets content of blob and write the result or error to stdout or stderr
-func (b *Blob) DataPipeline(stdout, stderr io.Writer) error {
- return NewCommand("show", b.ID.String()).RunInDirPipeline(b.repo.Path, stdout, stderr)
-}
-
-type cmdReadCloser struct {
- cmd *exec.Cmd
- stdout io.Reader
-}
-
-func (c cmdReadCloser) Read(p []byte) (int, error) {
- return c.stdout.Read(p)
-}
-
-func (c cmdReadCloser) Close() error {
- io.Copy(ioutil.Discard, c.stdout)
- return c.cmd.Wait()
-}
-
-// DataAsync gets a ReadCloser for the contents of a blob without reading it all.
-// Calling the Close function on the result will discard all unread output.
-func (b *Blob) DataAsync() (io.ReadCloser, error) {
- cmd := exec.Command("git", "show", b.ID.String())
- cmd.Dir = b.repo.Path
- cmd.Stderr = os.Stderr
-
- stdout, err := cmd.StdoutPipe()
- if err != nil {
- return nil, fmt.Errorf("StdoutPipe: %v", err)
- }
-
- if err = cmd.Start(); err != nil {
- return nil, fmt.Errorf("Start: %v", err)
- }
-
- return cmdReadCloser{stdout: stdout, cmd: cmd}, nil
-}
diff --git a/vendor/code.gitea.io/git/cache.go b/vendor/code.gitea.io/git/cache.go
deleted file mode 100644
index dbbbafae4c..0000000000
--- a/vendor/code.gitea.io/git/cache.go
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2019 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
-
-// LastCommitCache cache
-type LastCommitCache interface {
- Get(repoPath, ref, entryPath string) (*Commit, error)
- Put(repoPath, ref, entryPath string, commit *Commit) error
-}
diff --git a/vendor/code.gitea.io/git/command.go b/vendor/code.gitea.io/git/command.go
deleted file mode 100644
index fc48d2871b..0000000000
--- a/vendor/code.gitea.io/git/command.go
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "bytes"
- "context"
- "fmt"
- "io"
- "os/exec"
- "strings"
- "time"
-)
-
-var (
- // GlobalCommandArgs global command args for external package setting
- GlobalCommandArgs []string
-
- // DefaultCommandExecutionTimeout default command execution timeout duration
- DefaultCommandExecutionTimeout = 60 * time.Second
-)
-
-// Command represents a command with its subcommands or arguments.
-type Command struct {
- name string
- args []string
-}
-
-func (c *Command) String() string {
- if len(c.args) == 0 {
- return c.name
- }
- return fmt.Sprintf("%s %s", c.name, strings.Join(c.args, " "))
-}
-
-// 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(cargs, args...),
- }
-}
-
-// AddArguments adds new argument(s) to the command.
-func (c *Command) AddArguments(args ...string) *Command {
- c.args = append(c.args, args...)
- return c
-}
-
-// RunInDirTimeoutPipeline executes the command in given directory with given timeout,
-// it pipes stdout and stderr to given io.Writer.
-func (c *Command) RunInDirTimeoutPipeline(timeout time.Duration, dir string, stdout, stderr io.Writer) error {
- if timeout == -1 {
- timeout = DefaultCommandExecutionTimeout
- }
-
- if len(dir) == 0 {
- log(c.String())
- } else {
- log("%s: %v", dir, c)
- }
-
- ctx, cancel := context.WithTimeout(context.Background(), timeout)
- defer cancel()
-
- cmd := exec.CommandContext(ctx, c.name, c.args...)
- cmd.Dir = dir
- cmd.Stdout = stdout
- cmd.Stderr = stderr
- if err := cmd.Start(); err != nil {
- return err
- }
-
- if err := cmd.Wait(); err != nil {
- return err
- }
-
- return ctx.Err()
-}
-
-// RunInDirTimeout executes the command in given directory with given timeout,
-// and returns stdout in []byte and error (combined with stderr).
-func (c *Command) RunInDirTimeout(timeout time.Duration, dir string) ([]byte, error) {
- stdout := new(bytes.Buffer)
- stderr := new(bytes.Buffer)
- if err := c.RunInDirTimeoutPipeline(timeout, dir, stdout, stderr); err != nil {
- return nil, concatenateError(err, stderr.String())
- }
-
- if stdout.Len() > 0 {
- log("stdout:\n%s", stdout.Bytes()[:1024])
- }
- return stdout.Bytes(), nil
-}
-
-// RunInDirPipeline executes the command in given directory,
-// it pipes stdout and stderr to given io.Writer.
-func (c *Command) RunInDirPipeline(dir string, stdout, stderr io.Writer) error {
- return c.RunInDirTimeoutPipeline(-1, dir, stdout, stderr)
-}
-
-// RunInDirBytes executes the command in given directory
-// and returns stdout in []byte and error (combined with stderr).
-func (c *Command) RunInDirBytes(dir string) ([]byte, error) {
- return c.RunInDirTimeout(-1, dir)
-}
-
-// RunInDir executes the command in given directory
-// and returns stdout in string and error (combined with stderr).
-func (c *Command) RunInDir(dir string) (string, error) {
- stdout, err := c.RunInDirTimeout(-1, dir)
- if err != nil {
- return "", err
- }
- return string(stdout), nil
-}
-
-// RunTimeout executes the command in defualt working directory with given timeout,
-// and returns stdout in string and error (combined with stderr).
-func (c *Command) RunTimeout(timeout time.Duration) (string, error) {
- stdout, err := c.RunInDirTimeout(timeout, "")
- if err != nil {
- return "", err
- }
- return string(stdout), nil
-}
-
-// Run executes the command in defualt working directory
-// and returns stdout in string and error (combined with stderr).
-func (c *Command) Run() (string, error) {
- return c.RunTimeout(-1)
-}
diff --git a/vendor/code.gitea.io/git/commit.go b/vendor/code.gitea.io/git/commit.go
deleted file mode 100644
index 36b8d54565..0000000000
--- a/vendor/code.gitea.io/git/commit.go
+++ /dev/null
@@ -1,349 +0,0 @@
-// Copyright 2015 The Gogs Authors. All rights reserved.
-// 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 (
- "bufio"
- "bytes"
- "container/list"
- "fmt"
- "io"
- "net/http"
- "strconv"
- "strings"
-)
-
-// Commit represents a git commit.
-type Commit struct {
- Branch string // Branch this commit belongs to
- Tree
- ID SHA1 // The ID of this commit object
- Author *Signature
- Committer *Signature
- CommitMessage string
- Signature *CommitGPGSignature
-
- parents []SHA1 // SHA1 strings
- submoduleCache *ObjectCache
-}
-
-// CommitGPGSignature represents a git commit signature part.
-type CommitGPGSignature struct {
- Signature string
- Payload string //TODO check if can be reconstruct from the rest of commit information to not have duplicate data
-}
-
-// similar to https://github.com/git/git/blob/3bc53220cb2dcf709f7a027a3f526befd021d858/commit.c#L1128
-func newGPGSignatureFromCommitline(data []byte, signatureStart int, tag bool) (*CommitGPGSignature, error) {
- sig := new(CommitGPGSignature)
- signatureEnd := bytes.LastIndex(data, []byte("-----END PGP SIGNATURE-----"))
- if signatureEnd == -1 {
- return nil, fmt.Errorf("end of commit signature not found")
- }
- sig.Signature = strings.Replace(string(data[signatureStart:signatureEnd+27]), "\n ", "\n", -1)
- if tag {
- sig.Payload = string(data[:signatureStart-1])
- } else {
- sig.Payload = string(data[:signatureStart-8]) + string(data[signatureEnd+27:])
- }
- return sig, nil
-}
-
-// Message returns the commit message. Same as retrieving CommitMessage directly.
-func (c *Commit) Message() string {
- return c.CommitMessage
-}
-
-// Summary returns first line of commit message.
-func (c *Commit) Summary() string {
- return strings.Split(strings.TrimSpace(c.CommitMessage), "\n")[0]
-}
-
-// ParentID returns oid of n-th parent (0-based index).
-// It returns nil if no such parent exists.
-func (c *Commit) ParentID(n int) (SHA1, error) {
- if n >= len(c.parents) {
- return SHA1{}, ErrNotExist{"", ""}
- }
- return c.parents[n], nil
-}
-
-// Parent returns n-th parent (0-based index) of the commit.
-func (c *Commit) Parent(n int) (*Commit, error) {
- id, err := c.ParentID(n)
- if err != nil {
- return nil, err
- }
- parent, err := c.repo.getCommit(id)
- if err != nil {
- return nil, err
- }
- return parent, nil
-}
-
-// ParentCount returns number of parents of the commit.
-// 0 if this is the root commit, otherwise 1,2, etc.
-func (c *Commit) ParentCount() int {
- return len(c.parents)
-}
-
-func isImageFile(data []byte) (string, bool) {
- contentType := http.DetectContentType(data)
- if strings.Index(contentType, "image/") != -1 {
- return contentType, true
- }
- return contentType, false
-}
-
-// IsImageFile is a file image type
-func (c *Commit) IsImageFile(name string) bool {
- blob, err := c.GetBlobByPath(name)
- if err != nil {
- return false
- }
-
- dataRc, err := blob.DataAsync()
- if err != nil {
- return false
- }
- defer dataRc.Close()
- buf := make([]byte, 1024)
- n, _ := dataRc.Read(buf)
- buf = buf[:n]
- _, isImage := isImageFile(buf)
- return isImage
-}
-
-// GetCommitByPath return the commit of relative path object.
-func (c *Commit) GetCommitByPath(relpath string) (*Commit, error) {
- return c.repo.getCommitByPathWithID(c.ID, relpath)
-}
-
-// AddChanges marks local changes to be ready for commit.
-func AddChanges(repoPath string, all bool, files ...string) error {
- cmd := NewCommand("add")
- if all {
- cmd.AddArguments("--all")
- }
- _, err := cmd.AddArguments(files...).RunInDir(repoPath)
- return err
-}
-
-// CommitChangesOptions the options when a commit created
-type CommitChangesOptions struct {
- Committer *Signature
- Author *Signature
- Message string
-}
-
-// CommitChanges commits local changes with given committer, author and message.
-// If author is nil, it will be the same as committer.
-func CommitChanges(repoPath string, opts CommitChangesOptions) error {
- cmd := NewCommand()
- if opts.Committer != nil {
- cmd.AddArguments("-c", "user.name="+opts.Committer.Name, "-c", "user.email="+opts.Committer.Email)
- }
- cmd.AddArguments("commit")
-
- if opts.Author == nil {
- opts.Author = opts.Committer
- }
- if opts.Author != nil {
- cmd.AddArguments(fmt.Sprintf("--author='%s <%s>'", opts.Author.Name, opts.Author.Email))
- }
- cmd.AddArguments("-m", opts.Message)
-
- _, err := cmd.RunInDir(repoPath)
- // No stderr but exit status 1 means nothing to commit.
- if err != nil && err.Error() == "exit status 1" {
- return nil
- }
- return err
-}
-
-func commitsCount(repoPath, revision, relpath string) (int64, error) {
- var cmd *Command
- cmd = NewCommand("rev-list", "--count")
- cmd.AddArguments(revision)
- if len(relpath) > 0 {
- cmd.AddArguments("--", relpath)
- }
-
- stdout, err := cmd.RunInDir(repoPath)
- if err != nil {
- return 0, err
- }
-
- return strconv.ParseInt(strings.TrimSpace(stdout), 10, 64)
-}
-
-// CommitsCount returns number of total commits of until given revision.
-func CommitsCount(repoPath, revision string) (int64, error) {
- return commitsCount(repoPath, revision, "")
-}
-
-// CommitsCount returns number of total commits of until current revision.
-func (c *Commit) CommitsCount() (int64, error) {
- return CommitsCount(c.repo.Path, c.ID.String())
-}
-
-// CommitsByRange returns the specific page commits before current revision, every page's number default by CommitsRangeSize
-func (c *Commit) CommitsByRange(page int) (*list.List, error) {
- return c.repo.commitsByRange(c.ID, page)
-}
-
-// CommitsBefore returns all the commits before current revision
-func (c *Commit) CommitsBefore() (*list.List, error) {
- return c.repo.getCommitsBefore(c.ID)
-}
-
-// CommitsBeforeLimit returns num commits before current revision
-func (c *Commit) CommitsBeforeLimit(num int) (*list.List, error) {
- return c.repo.getCommitsBeforeLimit(c.ID, num)
-}
-
-// CommitsBeforeUntil returns the commits between commitID to current revision
-func (c *Commit) CommitsBeforeUntil(commitID string) (*list.List, error) {
- endCommit, err := c.repo.GetCommit(commitID)
- if err != nil {
- return nil, err
- }
- return c.repo.CommitsBetween(c, endCommit)
-}
-
-// SearchCommits returns the commits match the keyword before current revision
-func (c *Commit) SearchCommits(keyword string, all bool) (*list.List, error) {
- return c.repo.searchCommits(c.ID, keyword, all)
-}
-
-// GetFilesChangedSinceCommit get all changed file names between pastCommit to current revision
-func (c *Commit) GetFilesChangedSinceCommit(pastCommit string) ([]string, error) {
- return c.repo.getFilesChanged(pastCommit, c.ID.String())
-}
-
-// GetSubModules get all the sub modules of current revision git tree
-func (c *Commit) GetSubModules() (*ObjectCache, error) {
- if c.submoduleCache != nil {
- return c.submoduleCache, nil
- }
-
- entry, err := c.GetTreeEntryByPath(".gitmodules")
- if err != nil {
- if _, ok := err.(ErrNotExist); ok {
- return nil, nil
- }
- return nil, err
- }
- rd, err := entry.Blob().Data()
- if err != nil {
- return nil, err
- }
-
- scanner := bufio.NewScanner(rd)
- c.submoduleCache = newObjectCache()
- var ismodule bool
- var path string
- for scanner.Scan() {
- if strings.HasPrefix(scanner.Text(), "[submodule") {
- ismodule = true
- continue
- }
- if ismodule {
- fields := strings.Split(scanner.Text(), "=")
- k := strings.TrimSpace(fields[0])
- if k == "path" {
- path = strings.TrimSpace(fields[1])
- } else if k == "url" {
- c.submoduleCache.Set(path, &SubModule{path, strings.TrimSpace(fields[1])})
- ismodule = false
- }
- }
- }
-
- return c.submoduleCache, nil
-}
-
-// GetSubModule get the sub module according entryname
-func (c *Commit) GetSubModule(entryname string) (*SubModule, error) {
- modules, err := c.GetSubModules()
- if err != nil {
- return nil, err
- }
-
- if modules != nil {
- module, has := modules.Get(entryname)
- if has {
- return module.(*SubModule), nil
- }
- }
- return nil, nil
-}
-
-// CommitFileStatus represents status of files in a commit.
-type CommitFileStatus struct {
- Added []string
- Removed []string
- Modified []string
-}
-
-// NewCommitFileStatus creates a CommitFileStatus
-func NewCommitFileStatus() *CommitFileStatus {
- return &CommitFileStatus{
- []string{}, []string{}, []string{},
- }
-}
-
-// GetCommitFileStatus returns file status of commit in given repository.
-func GetCommitFileStatus(repoPath, commitID string) (*CommitFileStatus, error) {
- stdout, w := io.Pipe()
- done := make(chan struct{})
- fileStatus := NewCommitFileStatus()
- go func() {
- scanner := bufio.NewScanner(stdout)
- for scanner.Scan() {
- fields := strings.Fields(scanner.Text())
- if len(fields) < 2 {
- continue
- }
-
- switch fields[0][0] {
- case 'A':
- fileStatus.Added = append(fileStatus.Added, fields[1])
- case 'D':
- fileStatus.Removed = append(fileStatus.Removed, fields[1])
- case 'M':
- fileStatus.Modified = append(fileStatus.Modified, fields[1])
- }
- }
- done <- struct{}{}
- }()
-
- stderr := new(bytes.Buffer)
- err := NewCommand("show", "--name-status", "--pretty=format:''", commitID).RunInDirPipeline(repoPath, w, stderr)
- w.Close() // Close writer to exit parsing goroutine
- if err != nil {
- return nil, concatenateError(err, stderr.String())
- }
-
- <-done
- return fileStatus, nil
-}
-
-// GetFullCommitID returns full length (40) of commit ID by given short SHA in a repository.
-func GetFullCommitID(repoPath, shortID string) (string, error) {
- if len(shortID) >= 40 {
- return shortID, nil
- }
-
- commitID, err := NewCommand("rev-parse", shortID).RunInDir(repoPath)
- if err != nil {
- if strings.Contains(err.Error(), "exit status 128") {
- return "", ErrNotExist{shortID, ""}
- }
- return "", err
- }
- return strings.TrimSpace(commitID), nil
-}
diff --git a/vendor/code.gitea.io/git/commit_archive.go b/vendor/code.gitea.io/git/commit_archive.go
deleted file mode 100644
index e13825a962..0000000000
--- a/vendor/code.gitea.io/git/commit_archive.go
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "fmt"
- "path/filepath"
- "strings"
-)
-
-// ArchiveType archive types
-type ArchiveType int
-
-const (
- // ZIP zip archive type
- ZIP ArchiveType = iota + 1
- // TARGZ tar gz archive type
- TARGZ
-)
-
-// CreateArchive create archive content to the target path
-func (c *Commit) CreateArchive(target string, archiveType ArchiveType) error {
- var format string
- switch archiveType {
- case ZIP:
- format = "zip"
- case TARGZ:
- format = "tar.gz"
- default:
- return fmt.Errorf("unknown format: %v", archiveType)
- }
-
- _, err := NewCommand("archive", "--prefix="+filepath.Base(strings.TrimSuffix(c.repo.Path, ".git"))+"/", "--format="+format, "-o", target, c.ID.String()).RunInDir(c.repo.Path)
- return err
-}
diff --git a/vendor/code.gitea.io/git/commit_info.go b/vendor/code.gitea.io/git/commit_info.go
deleted file mode 100644
index 971082be1f..0000000000
--- a/vendor/code.gitea.io/git/commit_info.go
+++ /dev/null
@@ -1,329 +0,0 @@
-// Copyright 2017 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 (
- "bufio"
- "context"
- "fmt"
- "os/exec"
- "path"
- "runtime"
- "strconv"
- "strings"
- "sync"
- "time"
-)
-
-const (
- // parameters for searching for commit infos. If the untargeted search has
- // not found any entries in the past 5 commits, and 12 or fewer entries
- // remain, then we'll just let the targeted-searching threads finish off,
- // and stop the untargeted search to not interfere.
- deferToTargetedSearchColdStreak = 5
- deferToTargetedSearchNumRemainingEntries = 12
-)
-
-// getCommitsInfoState shared state while getting commit info for entries
-type getCommitsInfoState struct {
- lock sync.Mutex
- /* read-only fields, can be read without the mutex */
- // entries and entryPaths are read-only after initialization, so they can
- // safely be read without the mutex
- entries []*TreeEntry
- // set of filepaths to get info for
- entryPaths map[string]struct{}
- treePath string
- headCommit *Commit
-
- /* mutable fields, must hold mutex to read or write */
- // map from filepath to commit
- commits map[string]*Commit
- // set of filepaths that have been or are being searched for in a target search
- targetedPaths map[string]struct{}
-}
-
-func (state *getCommitsInfoState) numRemainingEntries() int {
- state.lock.Lock()
- defer state.lock.Unlock()
- return len(state.entries) - len(state.commits)
-}
-
-// getTargetEntryPath Returns the next path for a targeted-searching thread to
-// search for, or returns the empty string if nothing left to search for
-func (state *getCommitsInfoState) getTargetedEntryPath() string {
- var targetedEntryPath string
- state.lock.Lock()
- defer state.lock.Unlock()
- for _, entry := range state.entries {
- entryPath := path.Join(state.treePath, entry.Name())
- if _, ok := state.commits[entryPath]; ok {
- continue
- } else if _, ok = state.targetedPaths[entryPath]; ok {
- continue
- }
- targetedEntryPath = entryPath
- state.targetedPaths[entryPath] = struct{}{}
- break
- }
- return targetedEntryPath
-}
-
-// repeatedly perform targeted searches for unpopulated entries
-func targetedSearch(state *getCommitsInfoState, done chan error, cache LastCommitCache) {
- for {
- entryPath := state.getTargetedEntryPath()
- if len(entryPath) == 0 {
- done <- nil
- return
- }
- if cache != nil {
- commit, err := cache.Get(state.headCommit.repo.Path, state.headCommit.ID.String(), entryPath)
- if err == nil && commit != nil {
- state.update(entryPath, commit)
- continue
- }
- }
- command := NewCommand("rev-list", "-1", state.headCommit.ID.String(), "--", entryPath)
- output, err := command.RunInDir(state.headCommit.repo.Path)
- if err != nil {
- done <- err
- return
- }
- id, err := NewIDFromString(strings.TrimSpace(output))
- if err != nil {
- done <- err
- return
- }
- commit, err := state.headCommit.repo.getCommit(id)
- if err != nil {
- done <- err
- return
- }
- state.update(entryPath, commit)
- if cache != nil {
- cache.Put(state.headCommit.repo.Path, state.headCommit.ID.String(), entryPath, commit)
- }
- }
-}
-
-func initGetCommitInfoState(entries Entries, headCommit *Commit, treePath string) *getCommitsInfoState {
- entryPaths := make(map[string]struct{}, len(entries))
- for _, entry := range entries {
- entryPaths[path.Join(treePath, entry.Name())] = struct{}{}
- }
- if treePath = path.Clean(treePath); treePath == "." {
- treePath = ""
- }
- return &getCommitsInfoState{
- entries: entries,
- entryPaths: entryPaths,
- commits: make(map[string]*Commit, len(entries)),
- targetedPaths: make(map[string]struct{}, len(entries)),
- treePath: treePath,
- headCommit: headCommit,
- }
-}
-
-// GetCommitsInfo gets information of all commits that are corresponding to these entries
-func (tes Entries) GetCommitsInfo(commit *Commit, treePath string, cache LastCommitCache) ([][]interface{}, error) {
- state := initGetCommitInfoState(tes, commit, treePath)
- if err := getCommitsInfo(state, cache); err != nil {
- return nil, err
- }
- if len(state.commits) < len(state.entryPaths) {
- return nil, fmt.Errorf("could not find commits for all entries")
- }
-
- commitsInfo := make([][]interface{}, len(tes))
- for i, entry := range tes {
- commit, ok := state.commits[path.Join(treePath, entry.Name())]
- if !ok {
- return nil, fmt.Errorf("could not find commit for %s", entry.Name())
- }
- switch entry.Type {
- case ObjectCommit:
- subModuleURL := ""
- if subModule, err := state.headCommit.GetSubModule(entry.Name()); err != nil {
- return nil, err
- } else if subModule != nil {
- subModuleURL = subModule.URL
- }
- subModuleFile := NewSubModuleFile(commit, subModuleURL, entry.ID.String())
- commitsInfo[i] = []interface{}{entry, subModuleFile}
- default:
- commitsInfo[i] = []interface{}{entry, commit}
- }
- }
- return commitsInfo, nil
-}
-
-func (state *getCommitsInfoState) cleanEntryPath(rawEntryPath string) (string, error) {
- if rawEntryPath[0] == '"' {
- var err error
- rawEntryPath, err = strconv.Unquote(rawEntryPath)
- if err != nil {
- return rawEntryPath, err
- }
- }
- var entryNameStartIndex int
- if len(state.treePath) > 0 {
- entryNameStartIndex = len(state.treePath) + 1
- }
-
- if index := strings.IndexByte(rawEntryPath[entryNameStartIndex:], '/'); index >= 0 {
- return rawEntryPath[:entryNameStartIndex+index], nil
- }
- return rawEntryPath, nil
-}
-
-// update report that the given path was last modified by the given commit.
-// Returns whether state.commits was updated
-func (state *getCommitsInfoState) update(entryPath string, commit *Commit) bool {
- if _, ok := state.entryPaths[entryPath]; !ok {
- return false
- }
-
- var updated bool
- state.lock.Lock()
- defer state.lock.Unlock()
- if _, ok := state.commits[entryPath]; !ok {
- state.commits[entryPath] = commit
- updated = true
- }
- return updated
-}
-
-const getCommitsInfoPretty = "--pretty=format:%H %ct %s"
-
-func getCommitsInfo(state *getCommitsInfoState, cache LastCommitCache) error {
- ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
- defer cancel()
-
- args := []string{"log", state.headCommit.ID.String(), getCommitsInfoPretty, "--name-status", "-c"}
- if len(state.treePath) > 0 {
- args = append(args, "--", state.treePath)
- }
- cmd := exec.CommandContext(ctx, "git", args...)
- cmd.Dir = state.headCommit.repo.Path
-
- readCloser, err := cmd.StdoutPipe()
- if err != nil {
- return err
- }
-
- if err := cmd.Start(); err != nil {
- return err
- }
- // it's okay to ignore the error returned by cmd.Wait(); we expect the
- // subprocess to sometimes have a non-zero exit status, since we may
- // prematurely close stdout, resulting in a broken pipe.
- defer cmd.Wait()
-
- numThreads := runtime.NumCPU()
- done := make(chan error, numThreads)
- for i := 0; i < numThreads; i++ {
- go targetedSearch(state, done, cache)
- }
-
- scanner := bufio.NewScanner(readCloser)
- err = state.processGitLogOutput(scanner)
-
- // it is important that we close stdout here; if we do not close
- // stdout, the subprocess will keep running, and the deffered call
- // cmd.Wait() may block for a long time.
- if closeErr := readCloser.Close(); closeErr != nil && err == nil {
- err = closeErr
- }
-
- for i := 0; i < numThreads; i++ {
- doneErr := <-done
- if doneErr != nil && err == nil {
- err = doneErr
- }
- }
- return err
-}
-
-func (state *getCommitsInfoState) processGitLogOutput(scanner *bufio.Scanner) error {
- // keep a local cache of seen paths to avoid acquiring a lock for paths
- // we've already seen
- seenPaths := make(map[string]struct{}, len(state.entryPaths))
- // number of consecutive commits without any finds
- coldStreak := 0
- var commit *Commit
- var err error
- for scanner.Scan() {
- line := scanner.Text()
- if len(line) == 0 { // in-between commits
- numRemainingEntries := state.numRemainingEntries()
- if numRemainingEntries == 0 {
- break
- }
- if coldStreak >= deferToTargetedSearchColdStreak &&
- numRemainingEntries <= deferToTargetedSearchNumRemainingEntries {
- // stop this untargeted search, and let the targeted-search threads
- // finish the work
- break
- }
- continue
- }
- if line[0] >= 'A' && line[0] <= 'X' { // a file was changed by the current commit
- // look for the last tab, since for copies (C) and renames (R) two
- // filenames are printed: src, then dest
- tabIndex := strings.LastIndexByte(line, '\t')
- if tabIndex < 1 {
- return fmt.Errorf("misformatted line: %s", line)
- }
- entryPath, err := state.cleanEntryPath(line[tabIndex+1:])
- if err != nil {
- return err
- }
- if _, ok := seenPaths[entryPath]; !ok {
- if state.update(entryPath, commit) {
- coldStreak = 0
- }
- seenPaths[entryPath] = struct{}{}
- }
- continue
- }
-
- // a new commit
- commit, err = parseCommitInfo(line)
- if err != nil {
- return err
- }
- coldStreak++
- }
- return scanner.Err()
-}
-
-// parseCommitInfo parse a commit from a line of `git log` output. Expects the
-// line to be formatted according to getCommitsInfoPretty.
-func parseCommitInfo(line string) (*Commit, error) {
- if len(line) < 43 {
- return nil, fmt.Errorf("invalid git output: %s", line)
- }
- ref, err := NewIDFromString(line[:40])
- if err != nil {
- return nil, err
- }
- spaceIndex := strings.IndexByte(line[41:], ' ')
- if spaceIndex < 0 {
- return nil, fmt.Errorf("invalid git output: %s", line)
- }
- unixSeconds, err := strconv.Atoi(line[41 : 41+spaceIndex])
- if err != nil {
- return nil, err
- }
- message := line[spaceIndex+42:]
- return &Commit{
- ID: ref,
- CommitMessage: message,
- Committer: &Signature{
- When: time.Unix(int64(unixSeconds), 0),
- },
- }, nil
-}
diff --git a/vendor/code.gitea.io/git/doc.go b/vendor/code.gitea.io/git/doc.go
deleted file mode 100644
index 1941d28550..0000000000
--- a/vendor/code.gitea.io/git/doc.go
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright 2016 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 "code.gitea.io/git"
diff --git a/vendor/code.gitea.io/git/error.go b/vendor/code.gitea.io/git/error.go
deleted file mode 100644
index 1aae5a37a2..0000000000
--- a/vendor/code.gitea.io/git/error.go
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "fmt"
- "time"
-)
-
-// ErrExecTimeout error when exec timed out
-type ErrExecTimeout struct {
- Duration time.Duration
-}
-
-// IsErrExecTimeout if some error is ErrExecTimeout
-func IsErrExecTimeout(err error) bool {
- _, ok := err.(ErrExecTimeout)
- return ok
-}
-
-func (err ErrExecTimeout) Error() string {
- return fmt.Sprintf("execution is timeout [duration: %v]", err.Duration)
-}
-
-// ErrNotExist commit not exist error
-type ErrNotExist struct {
- ID string
- RelPath string
-}
-
-// IsErrNotExist if some error is ErrNotExist
-func IsErrNotExist(err error) bool {
- _, ok := err.(ErrNotExist)
- return ok
-}
-
-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
-}
-
-// IsErrUnsupportedVersion if some error is ErrUnsupportedVersion
-func IsErrUnsupportedVersion(err error) bool {
- _, ok := err.(ErrUnsupportedVersion)
- return ok
-}
-
-func (err ErrUnsupportedVersion) Error() string {
- return fmt.Sprintf("Operation requires higher version [required: %s]", err.Required)
-}
diff --git a/vendor/code.gitea.io/git/git.go b/vendor/code.gitea.io/git/git.go
deleted file mode 100644
index 150b80fb07..0000000000
--- a/vendor/code.gitea.io/git/git.go
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2015 The Gogs Authors. All rights reserved.
-// Copyright 2017 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 (
- "fmt"
- "strings"
- "time"
-
- "github.com/mcuadros/go-version"
-)
-
-// Version return this package's current version
-func Version() string {
- return "0.4.2"
-}
-
-var (
- // Debug enables verbose logging on everything.
- // This should be false in case Gogs starts in SSH mode.
- Debug = false
- // Prefix the log prefix
- Prefix = "[git-module] "
- // GitVersionRequired is the minimum Git version required
- GitVersionRequired = "1.7.2"
-)
-
-func log(format string, args ...interface{}) {
- if !Debug {
- return
- }
-
- fmt.Print(Prefix)
- if len(args) == 0 {
- fmt.Println(format)
- } else {
- fmt.Printf(format+"\n", args...)
- }
-}
-
-var gitVersion string
-
-// BinVersion returns current Git version from shell.
-func BinVersion() (string, error) {
- if len(gitVersion) > 0 {
- return gitVersion, nil
- }
-
- stdout, err := NewCommand("version").Run()
- if err != nil {
- return "", err
- }
-
- fields := strings.Fields(stdout)
- if len(fields) < 3 {
- return "", fmt.Errorf("not enough output: %s", stdout)
- }
-
- // Handle special case on Windows.
- i := strings.Index(fields[2], "windows")
- if i >= 1 {
- gitVersion = fields[2][:i-1]
- return gitVersion, nil
- }
-
- gitVersion = fields[2]
- return gitVersion, nil
-}
-
-func init() {
- gitVersion, err := BinVersion()
- if err != nil {
- panic(fmt.Sprintf("Git version missing: %v", err))
- }
- if version.Compare(gitVersion, GitVersionRequired, "<") {
- panic(fmt.Sprintf("Git version not supported. Requires version > %v", GitVersionRequired))
- }
-}
-
-// Fsck verifies the connectivity and validity of the objects in the database
-func Fsck(repoPath string, timeout time.Duration, args ...string) error {
- // Make sure timeout makes sense.
- if timeout <= 0 {
- timeout = -1
- }
- _, err := NewCommand("fsck").AddArguments(args...).RunInDirTimeout(timeout, repoPath)
- return err
-}
diff --git a/vendor/code.gitea.io/git/hook.go b/vendor/code.gitea.io/git/hook.go
deleted file mode 100644
index afed623e6e..0000000000
--- a/vendor/code.gitea.io/git/hook.go
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "errors"
- "io/ioutil"
- "os"
- "path"
- "path/filepath"
- "strings"
-
- "github.com/Unknwon/com"
-)
-
-// hookNames is a list of Git server hooks' name that are supported.
-var hookNames = []string{
- "pre-receive",
- "update",
- "post-receive",
-}
-
-var (
- // ErrNotValidHook error when a git hook is not valid
- ErrNotValidHook = errors.New("not a valid Git hook")
-)
-
-// IsValidHookName returns true if given name is a valid Git hook.
-func IsValidHookName(name string) bool {
- for _, hn := range hookNames {
- if hn == name {
- return true
- }
- }
- return false
-}
-
-// Hook represents a Git hook.
-type Hook struct {
- name string
- IsActive bool // Indicates whether repository has this hook.
- Content string // Content of hook if it's active.
- Sample string // Sample content from Git.
- path string // Hook file path.
-}
-
-// GetHook returns a Git hook by given name and repository.
-func GetHook(repoPath, name string) (*Hook, error) {
- if !IsValidHookName(name) {
- return nil, ErrNotValidHook
- }
- h := &Hook{
- name: name,
- path: path.Join(repoPath, "hooks", name+".d", name),
- }
- samplePath := filepath.Join(repoPath, "hooks", name+".sample")
- if isFile(h.path) {
- data, err := ioutil.ReadFile(h.path)
- if err != nil {
- return nil, err
- }
- h.IsActive = true
- h.Content = string(data)
- } else if isFile(samplePath) {
- data, err := ioutil.ReadFile(samplePath)
- if err != nil {
- return nil, err
- }
- h.Sample = string(data)
- }
- return h, nil
-}
-
-// Name return the name of the hook
-func (h *Hook) Name() string {
- return h.name
-}
-
-// Update updates hook settings.
-func (h *Hook) Update() error {
- if len(strings.TrimSpace(h.Content)) == 0 {
- if isExist(h.path) {
- return os.Remove(h.path)
- }
- return nil
- }
- return ioutil.WriteFile(h.path, []byte(strings.Replace(h.Content, "\r", "", -1)), os.ModePerm)
-}
-
-// ListHooks returns a list of Git hooks of given repository.
-func ListHooks(repoPath string) (_ []*Hook, err error) {
- if !isDir(path.Join(repoPath, "hooks")) {
- return nil, errors.New("hooks path does not exist")
- }
-
- hooks := make([]*Hook, len(hookNames))
- for i, name := range hookNames {
- hooks[i], err = GetHook(repoPath, name)
- if err != nil {
- return nil, err
- }
- }
- return hooks, nil
-}
-
-const (
- // HookPathUpdate hook update path
- HookPathUpdate = "hooks/update"
-)
-
-// SetUpdateHook writes given content to update hook of the reposiotry.
-func SetUpdateHook(repoPath, content string) (err error) {
- log("Setting update hook: %s", repoPath)
- hookPath := path.Join(repoPath, HookPathUpdate)
- if com.IsExist(hookPath) {
- err = os.Remove(hookPath)
- } else {
- err = os.MkdirAll(path.Dir(hookPath), os.ModePerm)
- }
- if err != nil {
- return err
- }
- return ioutil.WriteFile(hookPath, []byte(content), 0777)
-}
diff --git a/vendor/code.gitea.io/git/parse.go b/vendor/code.gitea.io/git/parse.go
deleted file mode 100644
index 5c964f16ee..0000000000
--- a/vendor/code.gitea.io/git/parse.go
+++ /dev/null
@@ -1,81 +0,0 @@
-// 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
-}
diff --git a/vendor/code.gitea.io/git/ref.go b/vendor/code.gitea.io/git/ref.go
deleted file mode 100644
index 67b56ac999..0000000000
--- a/vendor/code.gitea.io/git/ref.go
+++ /dev/null
@@ -1,18 +0,0 @@
-// 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
-
-// Reference represents a Git ref.
-type Reference struct {
- Name string
- repo *Repository
- Object SHA1 // The id of this commit object
- Type string
-}
-
-// Commit return the commit of the reference
-func (ref *Reference) Commit() (*Commit, error) {
- return ref.repo.getCommit(ref.Object)
-}
diff --git a/vendor/code.gitea.io/git/repo.go b/vendor/code.gitea.io/git/repo.go
deleted file mode 100644
index 4306730920..0000000000
--- a/vendor/code.gitea.io/git/repo.go
+++ /dev/null
@@ -1,287 +0,0 @@
-// Copyright 2015 The Gogs Authors. All rights reserved.
-// Copyright 2017 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"
- "container/list"
- "errors"
- "os"
- "path"
- "path/filepath"
- "strings"
- "time"
-
- "github.com/Unknwon/com"
-)
-
-// Repository represents a Git repository.
-type Repository struct {
- Path string
-
- commitCache *ObjectCache
- tagCache *ObjectCache
-}
-
-const prettyLogFormat = `--pretty=format:%H`
-
-func (repo *Repository) parsePrettyFormatLogToList(logs []byte) (*list.List, error) {
- l := list.New()
- if len(logs) == 0 {
- return l, nil
- }
-
- parts := bytes.Split(logs, []byte{'\n'})
-
- for _, commitID := range parts {
- commit, err := repo.GetCommit(string(commitID))
- if err != nil {
- return nil, err
- }
- l.PushBack(commit)
- }
-
- return l, nil
-}
-
-// IsRepoURLAccessible checks if given repository URL is accessible.
-func IsRepoURLAccessible(url string) bool {
- _, err := NewCommand("ls-remote", "-q", "-h", url, "HEAD").Run()
- if err != nil {
- return false
- }
- return true
-}
-
-// InitRepository initializes a new Git repository.
-func InitRepository(repoPath string, bare bool) error {
- os.MkdirAll(repoPath, os.ModePerm)
-
- cmd := NewCommand("init")
- if bare {
- cmd.AddArguments("--bare")
- }
- _, err := cmd.RunInDir(repoPath)
- return err
-}
-
-// OpenRepository opens the repository at the given path.
-func OpenRepository(repoPath string) (*Repository, error) {
- repoPath, err := filepath.Abs(repoPath)
- if err != nil {
- return nil, err
- } else if !isDir(repoPath) {
- return nil, errors.New("no such file or directory")
- }
-
- return &Repository{
- Path: repoPath,
- commitCache: newObjectCache(),
- tagCache: newObjectCache(),
- }, nil
-}
-
-// CloneRepoOptions options when clone a repository
-type CloneRepoOptions struct {
- Timeout time.Duration
- Mirror bool
- Bare bool
- Quiet bool
- Branch string
-}
-
-// Clone clones original repository to target path.
-func Clone(from, to string, opts CloneRepoOptions) (err error) {
- toDir := path.Dir(to)
- if err = os.MkdirAll(toDir, os.ModePerm); err != nil {
- return err
- }
-
- cmd := NewCommand("clone")
- if opts.Mirror {
- cmd.AddArguments("--mirror")
- }
- if opts.Bare {
- cmd.AddArguments("--bare")
- }
- if opts.Quiet {
- cmd.AddArguments("--quiet")
- }
- if len(opts.Branch) > 0 {
- cmd.AddArguments("-b", opts.Branch)
- }
- cmd.AddArguments(from, to)
-
- if opts.Timeout <= 0 {
- opts.Timeout = -1
- }
-
- _, err = cmd.RunTimeout(opts.Timeout)
- return err
-}
-
-// PullRemoteOptions options when pull from remote
-type PullRemoteOptions struct {
- Timeout time.Duration
- All bool
- Rebase bool
- Remote string
- Branch string
-}
-
-// Pull pulls changes from remotes.
-func Pull(repoPath string, opts PullRemoteOptions) error {
- cmd := NewCommand("pull")
- if opts.Rebase {
- cmd.AddArguments("--rebase")
- }
- if opts.All {
- cmd.AddArguments("--all")
- } else {
- cmd.AddArguments(opts.Remote)
- cmd.AddArguments(opts.Branch)
- }
-
- if opts.Timeout <= 0 {
- opts.Timeout = -1
- }
-
- _, err := cmd.RunInDirTimeout(opts.Timeout, repoPath)
- return err
-}
-
-// PushOptions options when push to remote
-type PushOptions struct {
- Remote string
- Branch string
- Force bool
-}
-
-// Push pushs local commits to given remote branch.
-func Push(repoPath string, opts PushOptions) error {
- cmd := NewCommand("push")
- if opts.Force {
- cmd.AddArguments("-f")
- }
- cmd.AddArguments(opts.Remote, opts.Branch)
- _, err := cmd.RunInDir(repoPath)
- return err
-}
-
-// CheckoutOptions options when heck out some branch
-type CheckoutOptions struct {
- Timeout time.Duration
- Branch string
- OldBranch string
-}
-
-// Checkout checkouts a branch
-func Checkout(repoPath string, opts CheckoutOptions) error {
- cmd := NewCommand("checkout")
- if len(opts.OldBranch) > 0 {
- cmd.AddArguments("-b")
- }
-
- if opts.Timeout <= 0 {
- opts.Timeout = -1
- }
-
- cmd.AddArguments(opts.Branch)
-
- if len(opts.OldBranch) > 0 {
- cmd.AddArguments(opts.OldBranch)
- }
-
- _, err := cmd.RunInDirTimeout(opts.Timeout, repoPath)
- return err
-}
-
-// ResetHEAD resets HEAD to given revision or head of branch.
-func ResetHEAD(repoPath string, hard bool, revision string) error {
- cmd := NewCommand("reset")
- if hard {
- cmd.AddArguments("--hard")
- }
- _, err := cmd.AddArguments(revision).RunInDir(repoPath)
- return err
-}
-
-// MoveFile moves a file to another file or directory.
-func MoveFile(repoPath, oldTreeName, newTreeName string) error {
- _, err := NewCommand("mv").AddArguments(oldTreeName, newTreeName).RunInDir(repoPath)
- return err
-}
-
-// CountObject represents repository count objects report
-type CountObject struct {
- Count int64
- Size int64
- InPack int64
- Packs int64
- SizePack int64
- PrunePack int64
- Garbage int64
- SizeGarbage int64
-}
-
-const (
- statCount = "count: "
- statSize = "size: "
- statInpack = "in-pack: "
- statPacks = "packs: "
- statSizePack = "size-pack: "
- statPrunePackage = "prune-package: "
- statGarbage = "garbage: "
- statSizeGarbage = "size-garbage: "
-)
-
-// GetRepoSize returns disk consumption for repo in path
-func GetRepoSize(repoPath string) (*CountObject, error) {
- cmd := NewCommand("count-objects", "-v")
- stdout, err := cmd.RunInDir(repoPath)
- if err != nil {
- return nil, err
- }
-
- return parseSize(stdout), nil
-}
-
-// parseSize parses the output from count-objects and return a CountObject
-func parseSize(objects string) *CountObject {
- repoSize := new(CountObject)
- for _, line := range strings.Split(objects, "\n") {
- switch {
- case strings.HasPrefix(line, statCount):
- repoSize.Count = com.StrTo(line[7:]).MustInt64()
- case strings.HasPrefix(line, statSize):
- repoSize.Size = com.StrTo(line[6:]).MustInt64() * 1024
- case strings.HasPrefix(line, statInpack):
- repoSize.InPack = com.StrTo(line[9:]).MustInt64()
- case strings.HasPrefix(line, statPacks):
- repoSize.Packs = com.StrTo(line[7:]).MustInt64()
- case strings.HasPrefix(line, statSizePack):
- repoSize.SizePack = com.StrTo(line[11:]).MustInt64() * 1024
- case strings.HasPrefix(line, statPrunePackage):
- repoSize.PrunePack = com.StrTo(line[16:]).MustInt64()
- case strings.HasPrefix(line, statGarbage):
- repoSize.Garbage = com.StrTo(line[9:]).MustInt64()
- case strings.HasPrefix(line, statSizeGarbage):
- repoSize.SizeGarbage = com.StrTo(line[14:]).MustInt64() * 1024
- }
- }
- return repoSize
-}
-
-// GetLatestCommitTime returns time for latest commit in repository (across all branches)
-func GetLatestCommitTime(repoPath string) (time.Time, error) {
- cmd := NewCommand("for-each-ref", "--sort=-committerdate", "refs/heads/", "--count", "1", "--format=%(committerdate)")
- stdout, err := cmd.RunInDir(repoPath)
- if err != nil {
- return time.Time{}, err
- }
- commitTime := strings.TrimSpace(stdout)
- return time.Parse(GitTimeLayout, commitTime)
-}
diff --git a/vendor/code.gitea.io/git/repo_blame.go b/vendor/code.gitea.io/git/repo_blame.go
deleted file mode 100644
index 80ec50e472..0000000000
--- a/vendor/code.gitea.io/git/repo_blame.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2017 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 "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)
-}
-
-// 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]))
-}
diff --git a/vendor/code.gitea.io/git/repo_blob.go b/vendor/code.gitea.io/git/repo_blob.go
deleted file mode 100644
index a9445a1f7a..0000000000
--- a/vendor/code.gitea.io/git/repo_blob.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// 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
-
-func (repo *Repository) getBlob(id SHA1) (*Blob, error) {
- if _, err := NewCommand("cat-file", "-p", id.String()).RunInDir(repo.Path); err != nil {
- return nil, ErrNotExist{id.String(), ""}
- }
-
- return &Blob{
- repo: repo,
- TreeEntry: &TreeEntry{
- ID: id,
- ptree: &Tree{
- repo: repo,
- },
- },
- }, nil
-}
-
-// GetBlob finds the blob object in the repository.
-func (repo *Repository) GetBlob(idStr string) (*Blob, error) {
- id, err := NewIDFromString(idStr)
- if err != nil {
- return nil, err
- }
- return repo.getBlob(id)
-}
diff --git a/vendor/code.gitea.io/git/repo_branch.go b/vendor/code.gitea.io/git/repo_branch.go
deleted file mode 100644
index 6414abbec5..0000000000
--- a/vendor/code.gitea.io/git/repo_branch.go
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright 2015 The Gogs Authors. All rights reserved.
-// 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 (
- "fmt"
- "strings"
-
- "gopkg.in/src-d/go-git.v4"
- "gopkg.in/src-d/go-git.v4/plumbing"
-)
-
-// BranchPrefix base dir of the branch information file store on git
-const BranchPrefix = "refs/heads/"
-
-// IsReferenceExist returns true if given reference exists in the repository.
-func IsReferenceExist(repoPath, name string) bool {
- _, err := NewCommand("show-ref", "--verify", name).RunInDir(repoPath)
- return err == nil
-}
-
-// IsBranchExist returns true if given branch exists in the repository.
-func IsBranchExist(repoPath, name string) bool {
- return IsReferenceExist(repoPath, BranchPrefix+name)
-}
-
-// IsBranchExist returns true if given branch exists in current repository.
-func (repo *Repository) IsBranchExist(name string) bool {
- return IsBranchExist(repo.Path, name)
-}
-
-// Branch represents a Git branch.
-type Branch struct {
- Name string
- Path string
-}
-
-// GetHEADBranch returns corresponding branch of HEAD.
-func (repo *Repository) GetHEADBranch() (*Branch, error) {
- stdout, err := NewCommand("symbolic-ref", "HEAD").RunInDir(repo.Path)
- if err != nil {
- return nil, err
- }
- stdout = strings.TrimSpace(stdout)
-
- if !strings.HasPrefix(stdout, BranchPrefix) {
- return nil, fmt.Errorf("invalid HEAD branch: %v", stdout)
- }
-
- return &Branch{
- Name: stdout[len(BranchPrefix):],
- Path: stdout,
- }, nil
-}
-
-// SetDefaultBranch sets default branch of repository.
-func (repo *Repository) SetDefaultBranch(name string) error {
- _, err := NewCommand("symbolic-ref", "HEAD", BranchPrefix+name).RunInDir(repo.Path)
- return err
-}
-
-// GetBranches returns all branches of the repository.
-func (repo *Repository) GetBranches() ([]string, error) {
- r, err := git.PlainOpen(repo.Path)
- if err != nil {
- return nil, err
- }
-
- branchIter, err := r.Branches()
- if err != nil {
- return nil, err
- }
- branches := make([]string, 0)
- if err = branchIter.ForEach(func(branch *plumbing.Reference) error {
- branches = append(branches, branch.Name().Short())
- return nil
- }); err != nil {
- return nil, err
- }
-
- return branches, nil
-}
-
-// DeleteBranchOptions Option(s) for delete branch
-type DeleteBranchOptions struct {
- Force bool
-}
-
-// DeleteBranch delete a branch by name on repository.
-func (repo *Repository) DeleteBranch(name string, opts DeleteBranchOptions) error {
- cmd := NewCommand("branch")
-
- if opts.Force {
- cmd.AddArguments("-D")
- } else {
- cmd.AddArguments("-d")
- }
-
- cmd.AddArguments(name)
- _, err := cmd.RunInDir(repo.Path)
-
- return err
-}
-
-// CreateBranch create a new branch
-func (repo *Repository) CreateBranch(branch, newBranch string) error {
- cmd := NewCommand("branch")
- cmd.AddArguments(branch, newBranch)
-
- _, err := cmd.RunInDir(repo.Path)
-
- return err
-}
-
-// AddRemote adds a new remote to repository.
-func (repo *Repository) AddRemote(name, url string, fetch bool) error {
- cmd := NewCommand("remote", "add")
- if fetch {
- cmd.AddArguments("-f")
- }
- cmd.AddArguments(name, url)
-
- _, err := cmd.RunInDir(repo.Path)
- return err
-}
-
-// RemoveRemote removes a remote from repository.
-func (repo *Repository) RemoveRemote(name string) error {
- _, err := NewCommand("remote", "remove", name).RunInDir(repo.Path)
- return err
-}
diff --git a/vendor/code.gitea.io/git/repo_commit.go b/vendor/code.gitea.io/git/repo_commit.go
deleted file mode 100644
index 2d9f5bdbf8..0000000000
--- a/vendor/code.gitea.io/git/repo_commit.go
+++ /dev/null
@@ -1,388 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "bytes"
- "container/list"
- "strconv"
- "strings"
-
- version "github.com/mcuadros/go-version"
-)
-
-// GetRefCommitID returns the last commit ID string of given reference (branch or tag).
-func (repo *Repository) GetRefCommitID(name string) (string, error) {
- stdout, err := NewCommand("show-ref", "--verify", name).RunInDir(repo.Path)
- if err != nil {
- if strings.Contains(err.Error(), "not a valid ref") {
- return "", ErrNotExist{name, ""}
- }
- return "", err
- }
- return strings.Split(stdout, " ")[0], nil
-}
-
-// GetBranchCommitID returns last commit ID string of given branch.
-func (repo *Repository) GetBranchCommitID(name string) (string, error) {
- return repo.GetRefCommitID(BranchPrefix + name)
-}
-
-// GetTagCommitID returns last commit ID string of given tag.
-func (repo *Repository) GetTagCommitID(name string) (string, error) {
- stdout, err := NewCommand("rev-list", "-n", "1", name).RunInDir(repo.Path)
- if err != nil {
- if strings.Contains(err.Error(), "unknown revision or path") {
- return "", ErrNotExist{name, ""}
- }
- return "", err
- }
- return strings.TrimSpace(stdout), nil
-}
-
-// parseCommitData parses commit information from the (uncompressed) raw
-// data from the commit object.
-// \n\n separate headers from message
-func parseCommitData(data []byte) (*Commit, error) {
- commit := new(Commit)
- commit.parents = make([]SHA1, 0, 1)
- // we now have the contents of the commit object. Let's investigate...
- nextline := 0
-l:
- for {
- eol := bytes.IndexByte(data[nextline:], '\n')
- switch {
- case eol > 0:
- line := data[nextline : nextline+eol]
- spacepos := bytes.IndexByte(line, ' ')
- reftype := line[:spacepos]
- switch string(reftype) {
- case "tree", "object":
- id, err := NewIDFromString(string(line[spacepos+1:]))
- if err != nil {
- return nil, err
- }
- commit.Tree.ID = id
- case "parent":
- // A commit can have one or more parents
- oid, err := NewIDFromString(string(line[spacepos+1:]))
- if err != nil {
- return nil, err
- }
- commit.parents = append(commit.parents, oid)
- case "author", "tagger":
- sig, err := newSignatureFromCommitline(line[spacepos+1:])
- if err != nil {
- return nil, err
- }
- commit.Author = sig
- case "committer":
- sig, err := newSignatureFromCommitline(line[spacepos+1:])
- if err != nil {
- return nil, err
- }
- commit.Committer = sig
- case "gpgsig":
- sig, err := newGPGSignatureFromCommitline(data, nextline+spacepos+1, false)
- if err != nil {
- return nil, err
- }
- commit.Signature = sig
- }
- nextline += eol + 1
- case eol == 0:
- cm := string(data[nextline+1:])
-
- // Tag GPG signatures are stored below the commit message
- sigindex := strings.Index(cm, "-----BEGIN PGP SIGNATURE-----")
- if sigindex != -1 {
- sig, err := newGPGSignatureFromCommitline(data, (nextline+1)+sigindex, true)
- if err == nil && sig != nil {
- // remove signature from commit message
- if sigindex == 0 {
- cm = ""
- } else {
- cm = cm[:sigindex-1]
- }
- commit.Signature = sig
- }
- }
-
- commit.CommitMessage = cm
- break l
- default:
- break l
- }
- }
- return commit, nil
-}
-
-func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
- c, ok := repo.commitCache.Get(id.String())
- if ok {
- log("Hit cache: %s", id)
- return c.(*Commit), nil
- }
-
- data, err := NewCommand("cat-file", "-p", id.String()).RunInDirBytes(repo.Path)
- if err != nil {
- if strings.Contains(err.Error(), "fatal: Not a valid object name") {
- return nil, ErrNotExist{id.String(), ""}
- }
- return nil, err
- }
-
- commit, err := parseCommitData(data)
- if err != nil {
- return nil, err
- }
- commit.repo = repo
- commit.ID = id
-
- data, err = NewCommand("name-rev", id.String()).RunInDirBytes(repo.Path)
- if err != nil {
- return nil, err
- }
-
- // name-rev commitID ouput will be "COMMIT_ID master" or "COMMIT_ID master~12"
- commit.Branch = strings.Split(strings.Split(string(data), " ")[1], "~")[0]
-
- repo.commitCache.Set(id.String(), commit)
- return commit, nil
-}
-
-// GetCommit returns commit object of by ID string.
-func (repo *Repository) GetCommit(commitID string) (*Commit, error) {
- if len(commitID) != 40 {
- var err error
- actualCommitID, err := NewCommand("rev-parse", commitID).RunInDir(repo.Path)
- if err != nil {
- if strings.Contains(err.Error(), "unknown revision or path") {
- return nil, ErrNotExist{commitID, ""}
- }
- return nil, err
- }
- commitID = actualCommitID
- }
- id, err := NewIDFromString(commitID)
- if err != nil {
- return nil, err
- }
-
- return repo.getCommit(id)
-}
-
-// GetBranchCommit returns the last commit of given branch.
-func (repo *Repository) GetBranchCommit(name string) (*Commit, error) {
- commitID, err := repo.GetBranchCommitID(name)
- if err != nil {
- return nil, err
- }
- return repo.GetCommit(commitID)
-}
-
-// GetTagCommit get the commit of the specific tag via name
-func (repo *Repository) GetTagCommit(name string) (*Commit, error) {
- commitID, err := repo.GetTagCommitID(name)
- if err != nil {
- return nil, err
- }
- return repo.GetCommit(commitID)
-}
-
-func (repo *Repository) getCommitByPathWithID(id SHA1, relpath string) (*Commit, error) {
- // File name starts with ':' must be escaped.
- if relpath[0] == ':' {
- relpath = `\` + relpath
- }
-
- stdout, err := NewCommand("log", "-1", prettyLogFormat, id.String(), "--", relpath).RunInDir(repo.Path)
- if err != nil {
- return nil, err
- }
-
- id, err = NewIDFromString(stdout)
- if err != nil {
- return nil, err
- }
-
- return repo.getCommit(id)
-}
-
-// GetCommitByPath returns the last commit of relative path.
-func (repo *Repository) GetCommitByPath(relpath string) (*Commit, error) {
- stdout, err := NewCommand("log", "-1", prettyLogFormat, "--", relpath).RunInDirBytes(repo.Path)
- if err != nil {
- return nil, err
- }
-
- commits, err := repo.parsePrettyFormatLogToList(stdout)
- if err != nil {
- return nil, err
- }
- return commits.Front().Value.(*Commit), nil
-}
-
-// CommitsRangeSize the default commits range size
-var CommitsRangeSize = 50
-
-func (repo *Repository) commitsByRange(id SHA1, page int) (*list.List, error) {
- stdout, err := NewCommand("log", id.String(), "--skip="+strconv.Itoa((page-1)*CommitsRangeSize),
- "--max-count="+strconv.Itoa(CommitsRangeSize), prettyLogFormat).RunInDirBytes(repo.Path)
- if err != nil {
- return nil, err
- }
- return repo.parsePrettyFormatLogToList(stdout)
-}
-
-func (repo *Repository) searchCommits(id SHA1, keyword string, all bool) (*list.List, error) {
- cmd := NewCommand("log", id.String(), "-100", "-i", "--grep="+keyword, prettyLogFormat)
- if all {
- cmd.AddArguments("--all")
- }
- stdout, err := cmd.RunInDirBytes(repo.Path)
- if err != nil {
- return nil, err
- }
- return repo.parsePrettyFormatLogToList(stdout)
-}
-
-func (repo *Repository) getFilesChanged(id1 string, id2 string) ([]string, error) {
- stdout, err := NewCommand("diff", "--name-only", id1, id2).RunInDirBytes(repo.Path)
- if err != nil {
- return nil, err
- }
- return strings.Split(string(stdout), "\n"), nil
-}
-
-// FileCommitsCount return the number of files at a revison
-func (repo *Repository) FileCommitsCount(revision, file string) (int64, error) {
- return commitsCount(repo.Path, revision, file)
-}
-
-// CommitsByFileAndRange return the commits accroding revison file and the page
-func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (*list.List, error) {
- stdout, err := NewCommand("log", revision, "--follow", "--skip="+strconv.Itoa((page-1)*50),
- "--max-count="+strconv.Itoa(CommitsRangeSize), prettyLogFormat, "--", file).RunInDirBytes(repo.Path)
- if err != nil {
- return nil, err
- }
- return repo.parsePrettyFormatLogToList(stdout)
-}
-
-// FilesCountBetween return the number of files changed between two commits
-func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (int, error) {
- stdout, err := NewCommand("diff", "--name-only", startCommitID+"..."+endCommitID).RunInDir(repo.Path)
- if err != nil {
- return 0, err
- }
- return len(strings.Split(stdout, "\n")) - 1, nil
-}
-
-// CommitsBetween returns a list that contains commits between [last, before).
-func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List, error) {
- stdout, err := NewCommand("rev-list", before.ID.String()+"..."+last.ID.String()).RunInDirBytes(repo.Path)
- if err != nil {
- return nil, err
- }
- return repo.parsePrettyFormatLogToList(bytes.TrimSpace(stdout))
-}
-
-// CommitsBetweenIDs return commits between twoe commits
-func (repo *Repository) CommitsBetweenIDs(last, before string) (*list.List, error) {
- lastCommit, err := repo.GetCommit(last)
- if err != nil {
- return nil, err
- }
- beforeCommit, err := repo.GetCommit(before)
- if err != nil {
- return nil, err
- }
- return repo.CommitsBetween(lastCommit, beforeCommit)
-}
-
-// CommitsCountBetween return numbers of commits between two commits
-func (repo *Repository) CommitsCountBetween(start, end string) (int64, error) {
- return commitsCount(repo.Path, start+"..."+end, "")
-}
-
-// commitsBefore the limit is depth, not total number of returned commits.
-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())
- } else {
- cmd.AddArguments(prettyLogFormat, id.String())
- }
-
- stdout, err := cmd.RunInDirBytes(repo.Path)
- if err != nil {
- return nil, err
- }
-
- formattedLog, err := repo.parsePrettyFormatLogToList(bytes.TrimSpace(stdout))
- if err != nil {
- return nil, err
- }
-
- commits := list.New()
- for logEntry := formattedLog.Front(); logEntry != nil; logEntry = logEntry.Next() {
- commit := logEntry.Value.(*Commit)
- branches, err := repo.getBranches(commit, 2)
- if err != nil {
- return nil, err
- }
-
- if len(branches) > 1 {
- break
- }
-
- commits.PushBack(commit)
- }
-
- return commits, nil
-}
-
-func (repo *Repository) getCommitsBefore(id SHA1) (*list.List, error) {
- return repo.commitsBefore(id, 0)
-}
-
-func (repo *Repository) getCommitsBeforeLimit(id SHA1, num int) (*list.List, error) {
- return repo.commitsBefore(id, num)
-}
-
-func (repo *Repository) getBranches(commit *Commit, limit int) ([]string, error) {
- 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")
-
- 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
-}
diff --git a/vendor/code.gitea.io/git/repo_hook.go b/vendor/code.gitea.io/git/repo_hook.go
deleted file mode 100644
index 49f4d09fb6..0000000000
--- a/vendor/code.gitea.io/git/repo_hook.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2015 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 git
-
-// GetHook get one hook accroding the name on a repository
-func (repo *Repository) GetHook(name string) (*Hook, error) {
- return GetHook(repo.Path, name)
-}
-
-// Hooks get all the hooks on the repository
-func (repo *Repository) Hooks() ([]*Hook, error) {
- return ListHooks(repo.Path)
-}
diff --git a/vendor/code.gitea.io/git/repo_object.go b/vendor/code.gitea.io/git/repo_object.go
deleted file mode 100644
index 3be8400d22..0000000000
--- a/vendor/code.gitea.io/git/repo_object.go
+++ /dev/null
@@ -1,19 +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 git
-
-// ObjectType git object type
-type ObjectType string
-
-const (
- // ObjectCommit commit object type
- ObjectCommit ObjectType = "commit"
- // ObjectTree tree object type
- ObjectTree ObjectType = "tree"
- // ObjectBlob blob object type
- ObjectBlob ObjectType = "blob"
- // ObjectTag tag object type
- ObjectTag ObjectType = "tag"
-)
diff --git a/vendor/code.gitea.io/git/repo_pull.go b/vendor/code.gitea.io/git/repo_pull.go
deleted file mode 100644
index c6d97a6fd1..0000000000
--- a/vendor/code.gitea.io/git/repo_pull.go
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "bytes"
- "container/list"
- "fmt"
- "io"
- "strconv"
- "strings"
- "time"
-)
-
-// PullRequestInfo represents needed information for a pull request.
-type PullRequestInfo struct {
- MergeBase string
- Commits *list.List
- NumFiles int
-}
-
-// GetMergeBase checks and returns merge base of two branches.
-func (repo *Repository) GetMergeBase(base, head string) (string, error) {
- stdout, err := NewCommand("merge-base", base, head).RunInDir(repo.Path)
- return strings.TrimSpace(stdout), err
-}
-
-// GetPullRequestInfo generates and returns pull request information
-// between base and head branches of repositories.
-func (repo *Repository) GetPullRequestInfo(basePath, baseBranch, headBranch string) (_ *PullRequestInfo, err error) {
- var remoteBranch string
-
- // We don't need a temporary remote for same repository.
- if repo.Path != basePath {
- // Add a temporary remote
- tmpRemote := strconv.FormatInt(time.Now().UnixNano(), 10)
- if err = repo.AddRemote(tmpRemote, basePath, true); err != nil {
- return nil, fmt.Errorf("AddRemote: %v", err)
- }
- defer repo.RemoveRemote(tmpRemote)
-
- remoteBranch = "remotes/" + tmpRemote + "/" + baseBranch
- } else {
- remoteBranch = baseBranch
- }
-
- prInfo := new(PullRequestInfo)
- prInfo.MergeBase, err = repo.GetMergeBase(remoteBranch, headBranch)
- if err != nil {
- return nil, fmt.Errorf("GetMergeBase: %v", err)
- }
-
- logs, err := NewCommand("log", prInfo.MergeBase+"..."+headBranch, prettyLogFormat).RunInDirBytes(repo.Path)
- if err != nil {
- return nil, err
- }
- prInfo.Commits, err = repo.parsePrettyFormatLogToList(logs)
- if err != nil {
- return nil, fmt.Errorf("parsePrettyFormatLogToList: %v", err)
- }
-
- // Count number of changed files.
- stdout, err := NewCommand("diff", "--name-only", remoteBranch+"..."+headBranch).RunInDir(repo.Path)
- if err != nil {
- return nil, err
- }
- prInfo.NumFiles = len(strings.Split(stdout, "\n")) - 1
-
- return prInfo, nil
-}
-
-// GetPatch generates and returns patch data between given revisions.
-func (repo *Repository) GetPatch(base, head string) ([]byte, error) {
- return NewCommand("diff", "-p", "--binary", base, head).RunInDirBytes(repo.Path)
-}
-
-// GetFormatPatch generates and returns format-patch data between given revisions.
-func (repo *Repository) GetFormatPatch(base, head string) (io.Reader, error) {
- stdout := new(bytes.Buffer)
- stderr := new(bytes.Buffer)
-
- if err := NewCommand("format-patch", "--binary", "--stdout", base+"..."+head).
- RunInDirPipeline(repo.Path, stdout, stderr); err != nil {
- return nil, concatenateError(err, stderr.String())
- }
- return stdout, nil
-}
diff --git a/vendor/code.gitea.io/git/repo_ref.go b/vendor/code.gitea.io/git/repo_ref.go
deleted file mode 100644
index e1ab46e090..0000000000
--- a/vendor/code.gitea.io/git/repo_ref.go
+++ /dev/null
@@ -1,51 +0,0 @@
-// 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 (
- "strings"
-
- "gopkg.in/src-d/go-git.v4"
- "gopkg.in/src-d/go-git.v4/plumbing"
-)
-
-// GetRefs returns all references of the repository.
-func (repo *Repository) GetRefs() ([]*Reference, error) {
- return repo.GetRefsFiltered("")
-}
-
-// GetRefsFiltered returns all references of the repository that matches patterm exactly or starting with.
-func (repo *Repository) GetRefsFiltered(pattern string) ([]*Reference, error) {
- r, err := git.PlainOpen(repo.Path)
- if err != nil {
- return nil, err
- }
-
- refsIter, err := r.References()
- if err != nil {
- return nil, err
- }
- refs := make([]*Reference, 0)
- if err = refsIter.ForEach(func(ref *plumbing.Reference) error {
- if ref.Name() != plumbing.HEAD && !ref.Name().IsRemote() &&
- (pattern == "" || strings.HasPrefix(ref.Name().String(), pattern)) {
- r := &Reference{
- Name: ref.Name().String(),
- Object: SHA1(ref.Hash()),
- Type: string(ObjectCommit),
- repo: repo,
- }
- if ref.Name().IsTag() {
- r.Type = string(ObjectTag)
- }
- refs = append(refs, r)
- }
- return nil
- }); err != nil {
- return nil, err
- }
-
- return refs, nil
-}
diff --git a/vendor/code.gitea.io/git/repo_tag.go b/vendor/code.gitea.io/git/repo_tag.go
deleted file mode 100644
index 84825d7dc3..0000000000
--- a/vendor/code.gitea.io/git/repo_tag.go
+++ /dev/null
@@ -1,149 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "strings"
-
- "github.com/mcuadros/go-version"
-)
-
-// TagPrefix tags prefix path on the repository
-const TagPrefix = "refs/tags/"
-
-// IsTagExist returns true if given tag exists in the repository.
-func IsTagExist(repoPath, name string) bool {
- return IsReferenceExist(repoPath, TagPrefix+name)
-}
-
-// IsTagExist returns true if given tag exists in the repository.
-func (repo *Repository) IsTagExist(name string) bool {
- return IsTagExist(repo.Path, name)
-}
-
-// CreateTag create one tag in the repository
-func (repo *Repository) CreateTag(name, revision string) error {
- _, err := NewCommand("tag", name, revision).RunInDir(repo.Path)
- return err
-}
-
-func (repo *Repository) getTag(id SHA1) (*Tag, error) {
- t, ok := repo.tagCache.Get(id.String())
- if ok {
- log("Hit cache: %s", id)
- return t.(*Tag), nil
- }
-
- // Get tag type
- tp, err := NewCommand("cat-file", "-t", id.String()).RunInDir(repo.Path)
- if err != nil {
- return nil, err
- }
- tp = strings.TrimSpace(tp)
-
- // Tag is a commit.
- if ObjectType(tp) == ObjectCommit {
- tag := &Tag{
- ID: id,
- Object: id,
- Type: string(ObjectCommit),
- repo: repo,
- }
-
- repo.tagCache.Set(id.String(), tag)
- return tag, nil
- }
-
- // Tag with message.
- data, err := NewCommand("cat-file", "-p", id.String()).RunInDirBytes(repo.Path)
- if err != nil {
- return nil, err
- }
-
- tag, err := parseTagData(data)
- if err != nil {
- return nil, err
- }
-
- tag.ID = id
- tag.repo = repo
-
- repo.tagCache.Set(id.String(), tag)
- return tag, nil
-}
-
-// GetTag returns a Git tag by given name.
-func (repo *Repository) GetTag(name string) (*Tag, error) {
- idStr, err := repo.GetTagCommitID(name)
- if err != nil {
- return nil, err
- }
-
- id, err := NewIDFromString(idStr)
- if err != nil {
- return nil, err
- }
-
- tag, err := repo.getTag(id)
- if err != nil {
- return nil, err
- }
- tag.Name = name
- return tag, nil
-}
-
-// GetTagInfos returns all tag infos of the repository.
-func (repo *Repository) GetTagInfos() ([]*Tag, error) {
- // TODO this a slow implementation, makes one git command per tag
- stdout, err := NewCommand("tag").RunInDir(repo.Path)
- if err != nil {
- return nil, err
- }
-
- tagNames := strings.Split(stdout, "\n")
- var tags = make([]*Tag, 0, len(tagNames))
- for _, tagName := range tagNames {
- tagName = strings.TrimSpace(tagName)
- if len(tagName) == 0 {
- continue
- }
-
- tag, err := repo.GetTag(tagName)
- if err != nil {
- return nil, err
- }
- tags = append(tags, tag)
- }
- sortTagsByTime(tags)
- return tags, nil
-}
-
-// GetTags returns all tags of the repository.
-func (repo *Repository) GetTags() ([]string, error) {
- cmd := NewCommand("tag", "-l")
- if version.Compare(gitVersion, "2.0.0", ">=") {
- cmd.AddArguments("--sort=-v:refname")
- }
-
- stdout, err := cmd.RunInDir(repo.Path)
- if err != nil {
- return nil, err
- }
-
- tags := strings.Split(stdout, "\n")
- tags = tags[:len(tags)-1]
-
- if version.Compare(gitVersion, "2.0.0", "<") {
- version.Sort(tags)
-
- // Reverse order
- for i := 0; i < len(tags)/2; i++ {
- j := len(tags) - i - 1
- tags[i], tags[j] = tags[j], tags[i]
- }
- }
-
- return tags, nil
-}
diff --git a/vendor/code.gitea.io/git/repo_tree.go b/vendor/code.gitea.io/git/repo_tree.go
deleted file mode 100644
index 146b919d7a..0000000000
--- a/vendor/code.gitea.io/git/repo_tree.go
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2015 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 git
-
-func (repo *Repository) getTree(id SHA1) (*Tree, error) {
- treePath := filepathFromSHA1(repo.Path, id.String())
- if isFile(treePath) {
- _, err := NewCommand("ls-tree", id.String()).RunInDir(repo.Path)
- if err != nil {
- return nil, ErrNotExist{id.String(), ""}
- }
- }
-
- return NewTree(repo, id), nil
-}
-
-// 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
- }
- return repo.getTree(id)
-}
diff --git a/vendor/code.gitea.io/git/sha1.go b/vendor/code.gitea.io/git/sha1.go
deleted file mode 100644
index 6c9d53949d..0000000000
--- a/vendor/code.gitea.io/git/sha1.go
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "bytes"
- "encoding/hex"
- "fmt"
- "strings"
-)
-
-// EmptySHA defines empty git SHA
-const EmptySHA = "0000000000000000000000000000000000000000"
-
-// SHA1 a git commit name
-type SHA1 [20]byte
-
-// Equal returns true if s has the same SHA1 as caller.
-// Support 40-length-string, []byte, SHA1.
-func (id SHA1) Equal(s2 interface{}) bool {
- switch v := s2.(type) {
- case string:
- if len(v) != 40 {
- return false
- }
- return v == id.String()
- case []byte:
- return bytes.Equal(v, id[:])
- case SHA1:
- return v == id
- default:
- return false
- }
-}
-
-// String returns string (hex) representation of the Oid.
-func (id SHA1) String() string {
- 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
- copy(id[:], b)
- return id
-}
-
-// NewID creates a new SHA1 from a [20]byte array.
-func NewID(b []byte) (SHA1, error) {
- if len(b) != 20 {
- return SHA1{}, fmt.Errorf("Length must be 20: %v", b)
- }
- return MustID(b), nil
-}
-
-// MustIDFromString always creates a new sha from a ID with no validation of input.
-func MustIDFromString(s string) SHA1 {
- b, _ := hex.DecodeString(s)
- return MustID(b)
-}
-
-// NewIDFromString creates a new SHA1 from a ID string of length 40.
-func NewIDFromString(s string) (SHA1, error) {
- var id SHA1
- s = strings.TrimSpace(s)
- if len(s) != 40 {
- return id, fmt.Errorf("Length must be 40: %s", s)
- }
- b, err := hex.DecodeString(s)
- if err != nil {
- return id, err
- }
- return NewID(b)
-}
diff --git a/vendor/code.gitea.io/git/signature.go b/vendor/code.gitea.io/git/signature.go
deleted file mode 100644
index e6ab247fd7..0000000000
--- a/vendor/code.gitea.io/git/signature.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "bytes"
- "strconv"
- "time"
-)
-
-// Signature represents the Author or Committer information.
-type Signature struct {
- Email string
- Name string
- When time.Time
-}
-
-const (
- // GitTimeLayout is the (default) time layout used by git.
- GitTimeLayout = "Mon Jan _2 15:04:05 2006 -0700"
-)
-
-// Helper to get a signature from the commit line, which looks like these:
-// author Patrick Gundlach <gundlach@speedata.de> 1378823654 +0200
-// author Patrick Gundlach <gundlach@speedata.de> Thu, 07 Apr 2005 22:13:13 +0200
-// but without the "author " at the beginning (this method should)
-// be used for author and committer.
-//
-// FIXME: include timezone for timestamp!
-func newSignatureFromCommitline(line []byte) (_ *Signature, err error) {
- sig := new(Signature)
- emailStart := bytes.IndexByte(line, '<')
- sig.Name = string(line[:emailStart-1])
- emailEnd := bytes.IndexByte(line, '>')
- sig.Email = string(line[emailStart+1 : emailEnd])
-
- // Check date format.
- if len(line) > emailEnd+2 {
- firstChar := line[emailEnd+2]
- if firstChar >= 48 && firstChar <= 57 {
- timestop := bytes.IndexByte(line[emailEnd+2:], ' ')
- timestring := string(line[emailEnd+2 : emailEnd+2+timestop])
- seconds, _ := strconv.ParseInt(timestring, 10, 64)
- sig.When = time.Unix(seconds, 0)
- } else {
- sig.When, err = time.Parse(GitTimeLayout, string(line[emailEnd+2:]))
- if err != nil {
- return nil, err
- }
- }
- } else {
- // Fall back to unix 0 time
- sig.When = time.Unix(0, 0)
- }
- return sig, nil
-}
diff --git a/vendor/code.gitea.io/git/submodule.go b/vendor/code.gitea.io/git/submodule.go
deleted file mode 100644
index 294df3986a..0000000000
--- a/vendor/code.gitea.io/git/submodule.go
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2015 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 git
-
-import "strings"
-
-// SubModule submodule is a reference on git repository
-type SubModule struct {
- Name string
- URL string
-}
-
-// SubModuleFile represents a file with submodule type.
-type SubModuleFile struct {
- *Commit
-
- refURL string
- refID string
-}
-
-// NewSubModuleFile create a new submodule file
-func NewSubModuleFile(c *Commit, refURL, refID string) *SubModuleFile {
- return &SubModuleFile{
- Commit: c,
- refURL: refURL,
- refID: refID,
- }
-}
-
-func getRefURL(refURL, urlPrefix, parentPath string) string {
- if refURL == "" {
- return ""
- }
-
- url := strings.TrimSuffix(refURL, ".git")
-
- // git://xxx/user/repo
- if strings.HasPrefix(url, "git://") {
- return "http://" + strings.TrimPrefix(url, "git://")
- }
-
- // http[s]://xxx/user/repo
- if strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://") {
- return url
- }
-
- // Relative url prefix check (according to git submodule documentation)
- if strings.HasPrefix(url, "./") || strings.HasPrefix(url, "../") {
- // ...construct and return correct submodule url here...
- idx := strings.Index(parentPath, "/src/")
- if idx == -1 {
- return url
- }
- return strings.TrimSuffix(urlPrefix, "/") + parentPath[:idx] + "/" + url
- }
-
- // sysuser@xxx:user/repo
- i := strings.Index(url, "@")
- j := strings.LastIndex(url, ":")
-
- // Only process when i < j because git+ssh://git@git.forwardbias.in/npploader.git
- if i > -1 && j > -1 && i < j {
- // fix problem with reverse proxy works only with local server
- if strings.Contains(urlPrefix, url[i+1:j]) {
- return urlPrefix + url[j+1:]
- }
- if strings.HasPrefix(url, "ssh://") || strings.HasPrefix(url, "git+ssh://") {
- k := strings.Index(url[j+1:], "/")
- return "http://" + url[i+1:j] + "/" + url[j+1:][k+1:]
- }
- return "http://" + url[i+1:j] + "/" + url[j+1:]
- }
-
- return url
-}
-
-// RefURL guesses and returns reference URL.
-func (sf *SubModuleFile) RefURL(urlPrefix string, parentPath string) string {
- return getRefURL(sf.refURL, urlPrefix, parentPath)
-}
-
-// RefID returns reference ID.
-func (sf *SubModuleFile) RefID() string {
- return sf.refID
-}
diff --git a/vendor/code.gitea.io/git/tag.go b/vendor/code.gitea.io/git/tag.go
deleted file mode 100644
index 500fd27491..0000000000
--- a/vendor/code.gitea.io/git/tag.go
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "bytes"
- "sort"
-)
-
-// Tag represents a Git tag.
-type Tag struct {
- Name string
- ID SHA1
- repo *Repository
- Object SHA1 // The id of this commit object
- Type string
- Tagger *Signature
- Message string
-}
-
-// Commit return the commit of the tag reference
-func (tag *Tag) Commit() (*Commit, error) {
- return tag.repo.getCommit(tag.Object)
-}
-
-// Parse commit information from the (uncompressed) raw
-// data from the commit object.
-// \n\n separate headers from message
-func parseTagData(data []byte) (*Tag, error) {
- tag := new(Tag)
- // we now have the contents of the commit object. Let's investigate...
- nextline := 0
-l:
- for {
- eol := bytes.IndexByte(data[nextline:], '\n')
- switch {
- case eol > 0:
- line := data[nextline : nextline+eol]
- spacepos := bytes.IndexByte(line, ' ')
- reftype := line[:spacepos]
- switch string(reftype) {
- case "object":
- id, err := NewIDFromString(string(line[spacepos+1:]))
- if err != nil {
- return nil, err
- }
- tag.Object = id
- case "type":
- // A commit can have one or more parents
- tag.Type = string(line[spacepos+1:])
- case "tagger":
- sig, err := newSignatureFromCommitline(line[spacepos+1:])
- if err != nil {
- return nil, err
- }
- tag.Tagger = sig
- }
- nextline += eol + 1
- case eol == 0:
- tag.Message = string(data[nextline+1:])
- break l
- default:
- break l
- }
- }
- return tag, nil
-}
-
-type tagSorter []*Tag
-
-func (ts tagSorter) Len() int {
- return len([]*Tag(ts))
-}
-
-func (ts tagSorter) Less(i, j int) bool {
- return []*Tag(ts)[i].Tagger.When.After([]*Tag(ts)[j].Tagger.When)
-}
-
-func (ts tagSorter) Swap(i, j int) {
- []*Tag(ts)[i], []*Tag(ts)[j] = []*Tag(ts)[j], []*Tag(ts)[i]
-}
-
-// sortTagsByTime
-func sortTagsByTime(tags []*Tag) {
- sorter := tagSorter(tags)
- sort.Sort(sorter)
-}
diff --git a/vendor/code.gitea.io/git/tree.go b/vendor/code.gitea.io/git/tree.go
deleted file mode 100644
index b65fe19409..0000000000
--- a/vendor/code.gitea.io/git/tree.go
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "strings"
-)
-
-// Tree represents a flat directory listing.
-type Tree struct {
- ID SHA1
- repo *Repository
-
- // parent tree
- ptree *Tree
-
- entries Entries
- entriesParsed bool
-
- entriesRecursive Entries
- entriesRecursiveParsed bool
-}
-
-// NewTree create a new tree according the repository and commit id
-func NewTree(repo *Repository, id SHA1) *Tree {
- return &Tree{
- ID: id,
- repo: repo,
- }
-}
-
-// SubTree get a sub tree by the sub dir path
-func (t *Tree) SubTree(rpath string) (*Tree, error) {
- if len(rpath) == 0 {
- return t, nil
- }
-
- paths := strings.Split(rpath, "/")
- var (
- err error
- g = t
- p = t
- te *TreeEntry
- )
- for _, name := range paths {
- te, err = p.GetTreeEntryByPath(name)
- if err != nil {
- return nil, err
- }
-
- g, err = t.repo.getTree(te.ID)
- if err != nil {
- return nil, err
- }
- g.ptree = p
- p = g
- }
- return g, nil
-}
-
-// ListEntries returns all entries of current tree.
-func (t *Tree) ListEntries() (Entries, error) {
- if t.entriesParsed {
- return t.entries, nil
- }
-
- stdout, err := NewCommand("ls-tree", t.ID.String()).RunInDirBytes(t.repo.Path)
- if err != nil {
- return nil, err
- }
-
- t.entries, err = parseTreeEntries(stdout, t)
- if err == nil {
- t.entriesParsed = true
- }
-
- return t.entries, err
-}
-
-// ListEntriesRecursive returns all entries of current tree recursively including all subtrees
-func (t *Tree) ListEntriesRecursive() (Entries, error) {
- if t.entriesRecursiveParsed {
- return t.entriesRecursive, nil
- }
- stdout, err := NewCommand("ls-tree", "-t", "-r", t.ID.String()).RunInDirBytes(t.repo.Path)
- if err != nil {
- return nil, err
- }
-
- t.entriesRecursive, err = parseTreeEntries(stdout, t)
- if err == nil {
- t.entriesRecursiveParsed = true
- }
-
- return t.entriesRecursive, err
-}
diff --git a/vendor/code.gitea.io/git/tree_blob.go b/vendor/code.gitea.io/git/tree_blob.go
deleted file mode 100644
index b3d205d8e1..0000000000
--- a/vendor/code.gitea.io/git/tree_blob.go
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "path"
- "strings"
-)
-
-// GetTreeEntryByPath get the tree entries accroding the sub dir
-func (t *Tree) GetTreeEntryByPath(relpath string) (*TreeEntry, error) {
- if len(relpath) == 0 {
- return &TreeEntry{
- ID: t.ID,
- Type: ObjectTree,
- mode: EntryModeTree,
- }, nil
- }
-
- relpath = path.Clean(relpath)
- parts := strings.Split(relpath, "/")
- var err error
- tree := t
- for i, name := range parts {
- if i == len(parts)-1 {
- entries, err := tree.ListEntries()
- if err != nil {
- return nil, err
- }
- for _, v := range entries {
- if v.name == name {
- return v, nil
- }
- }
- } else {
- tree, err = tree.SubTree(name)
- if err != nil {
- return nil, err
- }
- }
- }
- return nil, ErrNotExist{"", relpath}
-}
-
-// GetBlobByPath get the blob object accroding the path
-func (t *Tree) GetBlobByPath(relpath string) (*Blob, error) {
- entry, err := t.GetTreeEntryByPath(relpath)
- if err != nil {
- return nil, err
- }
-
- if !entry.IsDir() {
- return entry.Blob(), nil
- }
-
- return nil, ErrNotExist{"", relpath}
-}
diff --git a/vendor/code.gitea.io/git/tree_entry.go b/vendor/code.gitea.io/git/tree_entry.go
deleted file mode 100644
index ead0d4f5df..0000000000
--- a/vendor/code.gitea.io/git/tree_entry.go
+++ /dev/null
@@ -1,205 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "io"
- "sort"
- "strconv"
- "strings"
-)
-
-// EntryMode the type of the object in the git tree
-type EntryMode int
-
-// There are only a few file modes in Git. They look like unix file modes, but they can only be
-// one of these.
-const (
- // EntryModeBlob
- EntryModeBlob EntryMode = 0x0100644
- // EntryModeExec
- EntryModeExec EntryMode = 0x0100755
- // EntryModeSymlink
- EntryModeSymlink EntryMode = 0x0120000
- // EntryModeCommit
- EntryModeCommit EntryMode = 0x0160000
- // EntryModeTree
- EntryModeTree EntryMode = 0x0040000
-)
-
-// TreeEntry the leaf in the git tree
-type TreeEntry struct {
- ID SHA1
- Type ObjectType
-
- mode EntryMode
- name string
-
- ptree *Tree
-
- commited bool
-
- size int64
- sized bool
-}
-
-// Name returns the name of the entry
-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() {
- return 0
- } else if te.sized {
- return te.size
- }
-
- stdout, err := NewCommand("cat-file", "-s", te.ID.String()).RunInDir(te.ptree.repo.Path)
- if err != nil {
- return 0
- }
-
- te.sized = true
- te.size, _ = strconv.ParseInt(strings.TrimSpace(stdout), 10, 64)
- return te.size
-}
-
-// IsSubModule if the entry is a sub module
-func (te *TreeEntry) IsSubModule() bool {
- return te.mode == EntryModeCommit
-}
-
-// IsDir if the entry is a sub dir
-func (te *TreeEntry) IsDir() bool {
- return te.mode == EntryModeTree
-}
-
-// IsLink if the entry is a symlink
-func (te *TreeEntry) IsLink() bool {
- return te.mode == EntryModeSymlink
-}
-
-// Blob retrun the blob object the entry
-func (te *TreeEntry) Blob() *Blob {
- return &Blob{
- repo: te.ptree.repo,
- TreeEntry: te,
- }
-}
-
-// 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() {
- return ""
- }
- tree, err := te.ptree.SubTree(te.name)
- if err != nil {
- return te.name
- }
- entries, _ := tree.ListEntries()
- if len(entries) == 1 && entries[0].IsDir() {
- name := entries[0].GetSubJumpablePathName()
- if name != "" {
- return te.name + "/" + name
- }
- }
- return te.name
-}
-
-// Entries a list of entry
-type Entries []*TreeEntry
-
-type customSortableEntries struct {
- Comparer func(s1, s2 string) bool
- Entries
-}
-
-var sorter = []func(t1, t2 *TreeEntry, cmp func(s1, s2 string) bool) bool{
- func(t1, t2 *TreeEntry, cmp func(s1, s2 string) bool) bool {
- return (t1.IsDir() || t1.IsSubModule()) && !t2.IsDir() && !t2.IsSubModule()
- },
- func(t1, t2 *TreeEntry, cmp func(s1, s2 string) bool) bool {
- return cmp(t1.name, t2.name)
- },
-}
-
-func (ctes customSortableEntries) Len() int { return len(ctes.Entries) }
-
-func (ctes customSortableEntries) Swap(i, j int) {
- ctes.Entries[i], ctes.Entries[j] = ctes.Entries[j], ctes.Entries[i]
-}
-
-func (ctes customSortableEntries) Less(i, j int) bool {
- t1, t2 := ctes.Entries[i], ctes.Entries[j]
- var k int
- for k = 0; k < len(sorter)-1; k++ {
- s := sorter[k]
- switch {
- case s(t1, t2, ctes.Comparer):
- return true
- case s(t2, t1, ctes.Comparer):
- return false
- }
- }
- return sorter[k](t1, t2, ctes.Comparer)
-}
-
-// Sort sort the list of entry
-func (tes Entries) Sort() {
- sort.Sort(customSortableEntries{func(s1, s2 string) bool {
- return s1 < s2
- }, tes})
-}
-
-// CustomSort customizable string comparing sort entry list
-func (tes Entries) CustomSort(cmp func(s1, s2 string) bool) {
- sort.Sort(customSortableEntries{cmp, tes})
-}
diff --git a/vendor/code.gitea.io/git/utils.go b/vendor/code.gitea.io/git/utils.go
deleted file mode 100644
index 8f010321cf..0000000000
--- a/vendor/code.gitea.io/git/utils.go
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 2015 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 git
-
-import (
- "fmt"
- "os"
- "path/filepath"
- "strings"
- "sync"
-)
-
-// ObjectCache provides thread-safe cache opeations.
-type ObjectCache struct {
- lock sync.RWMutex
- cache map[string]interface{}
-}
-
-func newObjectCache() *ObjectCache {
- return &ObjectCache{
- cache: make(map[string]interface{}, 10),
- }
-}
-
-// Set add obj to cache
-func (oc *ObjectCache) Set(id string, obj interface{}) {
- oc.lock.Lock()
- defer oc.lock.Unlock()
-
- oc.cache[id] = obj
-}
-
-// Get get cached obj by id
-func (oc *ObjectCache) Get(id string) (interface{}, bool) {
- oc.lock.RLock()
- defer oc.lock.RUnlock()
-
- obj, has := oc.cache[id]
- return obj, has
-}
-
-// isDir returns true if given path is a directory,
-// or returns false when it's a file or does not exist.
-func isDir(dir string) bool {
- f, e := os.Stat(dir)
- if e != nil {
- return false
- }
- return f.IsDir()
-}
-
-// isFile returns true if given path is a file,
-// or returns false when it's a directory or does not exist.
-func isFile(filePath string) bool {
- f, e := os.Stat(filePath)
- if e != nil {
- return false
- }
- return !f.IsDir()
-}
-
-// isExist checks whether a file or directory exists.
-// It returns false when the file or directory does not exist.
-func isExist(path string) bool {
- _, err := os.Stat(path)
- return err == nil || os.IsExist(err)
-}
-
-func concatenateError(err error, stderr string) error {
- if len(stderr) == 0 {
- return err
- }
- return fmt.Errorf("%v - %s", err, stderr)
-}
-
-// If the object is stored in its own file (i.e not in a pack file),
-// this function returns the full path to the object file.
-// It does not test if the file exists.
-func filepathFromSHA1(rootdir, sha1 string) string {
- return filepath.Join(rootdir, "objects", sha1[:2], sha1[2:])
-}
-
-// RefEndName return the end name of a ref name
-func RefEndName(refStr string) string {
- if strings.HasPrefix(refStr, BranchPrefix) {
- return refStr[len(BranchPrefix):]
- }
-
- if strings.HasPrefix(refStr, TagPrefix) {
- return refStr[len(TagPrefix):]
- }
-
- return refStr
-}
diff --git a/vendor/github.com/stretchr/testify/require/doc.go b/vendor/github.com/stretchr/testify/require/doc.go
new file mode 100644
index 0000000000..169de39221
--- /dev/null
+++ b/vendor/github.com/stretchr/testify/require/doc.go
@@ -0,0 +1,28 @@
+// Package require implements the same assertions as the `assert` package but
+// stops test execution when a test fails.
+//
+// Example Usage
+//
+// The following is a complete example using require in a standard test function:
+// import (
+// "testing"
+// "github.com/stretchr/testify/require"
+// )
+//
+// func TestSomething(t *testing.T) {
+//
+// var a string = "Hello"
+// var b string = "Hello"
+//
+// require.Equal(t, a, b, "The two words should be the same.")
+//
+// }
+//
+// Assertions
+//
+// The `require` package have same global functions as in the `assert` package,
+// but instead of returning a boolean result they call `t.FailNow()`.
+//
+// Every assertion function also takes an optional string message as the final argument,
+// allowing custom error messages to be appended to the message the assertion method outputs.
+package require
diff --git a/vendor/github.com/stretchr/testify/require/forward_requirements.go b/vendor/github.com/stretchr/testify/require/forward_requirements.go
new file mode 100644
index 0000000000..ac71d40581
--- /dev/null
+++ b/vendor/github.com/stretchr/testify/require/forward_requirements.go
@@ -0,0 +1,16 @@
+package require
+
+// Assertions provides assertion methods around the
+// TestingT interface.
+type Assertions struct {
+ t TestingT
+}
+
+// New makes a new Assertions object for the specified TestingT.
+func New(t TestingT) *Assertions {
+ return &Assertions{
+ t: t,
+ }
+}
+
+//go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl -include-format-funcs
diff --git a/vendor/github.com/stretchr/testify/require/require.go b/vendor/github.com/stretchr/testify/require/require.go
new file mode 100644
index 0000000000..ac3c308788
--- /dev/null
+++ b/vendor/github.com/stretchr/testify/require/require.go
@@ -0,0 +1,867 @@
+/*
+* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
+* THIS FILE MUST NOT BE EDITED BY HAND
+ */
+
+package require
+
+import (
+ assert "github.com/stretchr/testify/assert"
+ http "net/http"
+ url "net/url"
+ time "time"
+)
+
+// Condition uses a Comparison to assert a complex condition.
+func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) {
+ if !assert.Condition(t, comp, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// Conditionf uses a Comparison to assert a complex condition.
+func Conditionf(t TestingT, comp assert.Comparison, msg string, args ...interface{}) {
+ if !assert.Conditionf(t, comp, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Contains asserts that the specified string, list(array, slice...) or map contains the
+// specified substring or element.
+//
+// assert.Contains(t, "Hello World", "World")
+// assert.Contains(t, ["Hello", "World"], "World")
+// assert.Contains(t, {"Hello": "World"}, "Hello")
+func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
+ if !assert.Contains(t, s, contains, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// Containsf asserts that the specified string, list(array, slice...) or map contains the
+// specified substring or element.
+//
+// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
+// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
+// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
+func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
+ if !assert.Containsf(t, s, contains, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists.
+func DirExists(t TestingT, path string, msgAndArgs ...interface{}) {
+ if !assert.DirExists(t, path, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists.
+func DirExistsf(t TestingT, path string, msg string, args ...interface{}) {
+ if !assert.DirExistsf(t, path, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
+// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
+// the number of appearances of each of them in both lists should match.
+//
+// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])
+func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{}) {
+ if !assert.ElementsMatch(t, listA, listB, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
+// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
+// the number of appearances of each of them in both lists should match.
+//
+// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
+func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) {
+ if !assert.ElementsMatchf(t, listA, listB, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
+// a slice or a channel with len == 0.
+//
+// assert.Empty(t, obj)
+func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
+ if !assert.Empty(t, object, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
+// a slice or a channel with len == 0.
+//
+// assert.Emptyf(t, obj, "error message %s", "formatted")
+func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
+ if !assert.Emptyf(t, object, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Equal asserts that two objects are equal.
+//
+// assert.Equal(t, 123, 123)
+//
+// Pointer variable equality is determined based on the equality of the
+// referenced values (as opposed to the memory addresses). Function equality
+// cannot be determined and will always fail.
+func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
+ if !assert.Equal(t, expected, actual, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// EqualError asserts that a function returned an error (i.e. not `nil`)
+// and that it is equal to the provided error.
+//
+// actualObj, err := SomeFunction()
+// assert.EqualError(t, err, expectedErrorString)
+func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) {
+ if !assert.EqualError(t, theError, errString, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
+// and that it is equal to the provided error.
+//
+// actualObj, err := SomeFunction()
+// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
+func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) {
+ if !assert.EqualErrorf(t, theError, errString, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// EqualValues asserts that two objects are equal or convertable to the same types
+// and equal.
+//
+// assert.EqualValues(t, uint32(123), int32(123))
+func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
+ if !assert.EqualValues(t, expected, actual, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// EqualValuesf asserts that two objects are equal or convertable to the same types
+// and equal.
+//
+// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123))
+func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
+ if !assert.EqualValuesf(t, expected, actual, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Equalf asserts that two objects are equal.
+//
+// assert.Equalf(t, 123, 123, "error message %s", "formatted")
+//
+// Pointer variable equality is determined based on the equality of the
+// referenced values (as opposed to the memory addresses). Function equality
+// cannot be determined and will always fail.
+func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
+ if !assert.Equalf(t, expected, actual, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Error asserts that a function returned an error (i.e. not `nil`).
+//
+// actualObj, err := SomeFunction()
+// if assert.Error(t, err) {
+// assert.Equal(t, expectedError, err)
+// }
+func Error(t TestingT, err error, msgAndArgs ...interface{}) {
+ if !assert.Error(t, err, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// Errorf asserts that a function returned an error (i.e. not `nil`).
+//
+// actualObj, err := SomeFunction()
+// if assert.Errorf(t, err, "error message %s", "formatted") {
+// assert.Equal(t, expectedErrorf, err)
+// }
+func Errorf(t TestingT, err error, msg string, args ...interface{}) {
+ if !assert.Errorf(t, err, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Exactly asserts that two objects are equal in value and type.
+//
+// assert.Exactly(t, int32(123), int64(123))
+func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
+ if !assert.Exactly(t, expected, actual, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// Exactlyf asserts that two objects are equal in value and type.
+//
+// assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123))
+func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
+ if !assert.Exactlyf(t, expected, actual, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Fail reports a failure through
+func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
+ if !assert.Fail(t, failureMessage, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// FailNow fails test
+func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
+ if !assert.FailNow(t, failureMessage, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// FailNowf fails test
+func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) {
+ if !assert.FailNowf(t, failureMessage, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Failf reports a failure through
+func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) {
+ if !assert.Failf(t, failureMessage, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// False asserts that the specified value is false.
+//
+// assert.False(t, myBool)
+func False(t TestingT, value bool, msgAndArgs ...interface{}) {
+ if !assert.False(t, value, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// Falsef asserts that the specified value is false.
+//
+// assert.Falsef(t, myBool, "error message %s", "formatted")
+func Falsef(t TestingT, value bool, msg string, args ...interface{}) {
+ if !assert.Falsef(t, value, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file.
+func FileExists(t TestingT, path string, msgAndArgs ...interface{}) {
+ if !assert.FileExists(t, path, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file.
+func FileExistsf(t TestingT, path string, msg string, args ...interface{}) {
+ if !assert.FileExistsf(t, path, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// HTTPBodyContains asserts that a specified handler returns a
+// body that contains a string.
+//
+// assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
+//
+// Returns whether the assertion was successful (true) or not (false).
+func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
+ if !assert.HTTPBodyContains(t, handler, method, url, values, str, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// HTTPBodyContainsf asserts that a specified handler returns a
+// body that contains a string.
+//
+// assert.HTTPBodyContainsf(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
+//
+// Returns whether the assertion was successful (true) or not (false).
+func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
+ if !assert.HTTPBodyContainsf(t, handler, method, url, values, str, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// HTTPBodyNotContains asserts that a specified handler returns a
+// body that does not contain a string.
+//
+// assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
+//
+// Returns whether the assertion was successful (true) or not (false).
+func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
+ if !assert.HTTPBodyNotContains(t, handler, method, url, values, str, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// HTTPBodyNotContainsf asserts that a specified handler returns a
+// body that does not contain a string.
+//
+// assert.HTTPBodyNotContainsf(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
+//
+// Returns whether the assertion was successful (true) or not (false).
+func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
+ if !assert.HTTPBodyNotContainsf(t, handler, method, url, values, str, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// HTTPError asserts that a specified handler returns an error status code.
+//
+// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
+//
+// Returns whether the assertion was successful (true) or not (false).
+func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
+ if !assert.HTTPError(t, handler, method, url, values, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// HTTPErrorf asserts that a specified handler returns an error status code.
+//
+// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
+//
+// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
+func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
+ if !assert.HTTPErrorf(t, handler, method, url, values, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// HTTPRedirect asserts that a specified handler returns a redirect status code.
+//
+// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
+//
+// Returns whether the assertion was successful (true) or not (false).
+func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
+ if !assert.HTTPRedirect(t, handler, method, url, values, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// HTTPRedirectf asserts that a specified handler returns a redirect status code.
+//
+// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
+//
+// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
+func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
+ if !assert.HTTPRedirectf(t, handler, method, url, values, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// HTTPSuccess asserts that a specified handler returns a success status code.
+//
+// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
+//
+// Returns whether the assertion was successful (true) or not (false).
+func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
+ if !assert.HTTPSuccess(t, handler, method, url, values, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// HTTPSuccessf asserts that a specified handler returns a success status code.
+//
+// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
+//
+// Returns whether the assertion was successful (true) or not (false).
+func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
+ if !assert.HTTPSuccessf(t, handler, method, url, values, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Implements asserts that an object is implemented by the specified interface.
+//
+// assert.Implements(t, (*MyInterface)(nil), new(MyObject))
+func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
+ if !assert.Implements(t, interfaceObject, object, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// Implementsf asserts that an object is implemented by the specified interface.
+//
+// assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
+func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
+ if !assert.Implementsf(t, interfaceObject, object, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// InDelta asserts that the two numerals are within delta of each other.
+//
+// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01)
+func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
+ if !assert.InDelta(t, expected, actual, delta, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
+func InDeltaMapValues(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
+ if !assert.InDeltaMapValues(t, expected, actual, delta, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
+func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
+ if !assert.InDeltaMapValuesf(t, expected, actual, delta, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// InDeltaSlice is the same as InDelta, except it compares two slices.
+func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
+ if !assert.InDeltaSlice(t, expected, actual, delta, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// InDeltaSlicef is the same as InDelta, except it compares two slices.
+func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
+ if !assert.InDeltaSlicef(t, expected, actual, delta, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// InDeltaf asserts that the two numerals are within delta of each other.
+//
+// assert.InDeltaf(t, math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
+func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
+ if !assert.InDeltaf(t, expected, actual, delta, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// InEpsilon asserts that expected and actual have a relative error less than epsilon
+func InEpsilon(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
+ if !assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
+func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
+ if !assert.InEpsilonSlice(t, expected, actual, epsilon, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
+func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
+ if !assert.InEpsilonSlicef(t, expected, actual, epsilon, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// InEpsilonf asserts that expected and actual have a relative error less than epsilon
+func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
+ if !assert.InEpsilonf(t, expected, actual, epsilon, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// IsType asserts that the specified objects are of the same type.
+func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
+ if !assert.IsType(t, expectedType, object, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// IsTypef asserts that the specified objects are of the same type.
+func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) {
+ if !assert.IsTypef(t, expectedType, object, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// JSONEq asserts that two JSON strings are equivalent.
+//
+// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
+func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) {
+ if !assert.JSONEq(t, expected, actual, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// JSONEqf asserts that two JSON strings are equivalent.
+//
+// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
+func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) {
+ if !assert.JSONEqf(t, expected, actual, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Len asserts that the specified object has specific length.
+// Len also fails if the object has a type that len() not accept.
+//
+// assert.Len(t, mySlice, 3)
+func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {
+ if !assert.Len(t, object, length, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// Lenf asserts that the specified object has specific length.
+// Lenf also fails if the object has a type that len() not accept.
+//
+// assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
+func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) {
+ if !assert.Lenf(t, object, length, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Nil asserts that the specified object is nil.
+//
+// assert.Nil(t, err)
+func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
+ if !assert.Nil(t, object, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// Nilf asserts that the specified object is nil.
+//
+// assert.Nilf(t, err, "error message %s", "formatted")
+func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) {
+ if !assert.Nilf(t, object, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// NoError asserts that a function returned no error (i.e. `nil`).
+//
+// actualObj, err := SomeFunction()
+// if assert.NoError(t, err) {
+// assert.Equal(t, expectedObj, actualObj)
+// }
+func NoError(t TestingT, err error, msgAndArgs ...interface{}) {
+ if !assert.NoError(t, err, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// NoErrorf asserts that a function returned no error (i.e. `nil`).
+//
+// actualObj, err := SomeFunction()
+// if assert.NoErrorf(t, err, "error message %s", "formatted") {
+// assert.Equal(t, expectedObj, actualObj)
+// }
+func NoErrorf(t TestingT, err error, msg string, args ...interface{}) {
+ if !assert.NoErrorf(t, err, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
+// specified substring or element.
+//
+// assert.NotContains(t, "Hello World", "Earth")
+// assert.NotContains(t, ["Hello", "World"], "Earth")
+// assert.NotContains(t, {"Hello": "World"}, "Earth")
+func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
+ if !assert.NotContains(t, s, contains, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
+// specified substring or element.
+//
+// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
+// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
+// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
+func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
+ if !assert.NotContainsf(t, s, contains, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
+// a slice or a channel with len == 0.
+//
+// if assert.NotEmpty(t, obj) {
+// assert.Equal(t, "two", obj[1])
+// }
+func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
+ if !assert.NotEmpty(t, object, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
+// a slice or a channel with len == 0.
+//
+// if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
+// assert.Equal(t, "two", obj[1])
+// }
+func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
+ if !assert.NotEmptyf(t, object, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// NotEqual asserts that the specified values are NOT equal.
+//
+// assert.NotEqual(t, obj1, obj2)
+//
+// Pointer variable equality is determined based on the equality of the
+// referenced values (as opposed to the memory addresses).
+func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
+ if !assert.NotEqual(t, expected, actual, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// NotEqualf asserts that the specified values are NOT equal.
+//
+// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
+//
+// Pointer variable equality is determined based on the equality of the
+// referenced values (as opposed to the memory addresses).
+func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
+ if !assert.NotEqualf(t, expected, actual, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// NotNil asserts that the specified object is not nil.
+//
+// assert.NotNil(t, err)
+func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
+ if !assert.NotNil(t, object, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// NotNilf asserts that the specified object is not nil.
+//
+// assert.NotNilf(t, err, "error message %s", "formatted")
+func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) {
+ if !assert.NotNilf(t, object, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
+//
+// assert.NotPanics(t, func(){ RemainCalm() })
+func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
+ if !assert.NotPanics(t, f, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
+//
+// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
+func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) {
+ if !assert.NotPanicsf(t, f, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// NotRegexp asserts that a specified regexp does not match a string.
+//
+// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
+// assert.NotRegexp(t, "^start", "it's not starting")
+func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
+ if !assert.NotRegexp(t, rx, str, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// NotRegexpf asserts that a specified regexp does not match a string.
+//
+// assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
+// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
+func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) {
+ if !assert.NotRegexpf(t, rx, str, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// NotSubset asserts that the specified list(array, slice...) contains not all
+// elements given in the specified subset(array, slice...).
+//
+// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
+func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) {
+ if !assert.NotSubset(t, list, subset, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// NotSubsetf asserts that the specified list(array, slice...) contains not all
+// elements given in the specified subset(array, slice...).
+//
+// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
+func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
+ if !assert.NotSubsetf(t, list, subset, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// NotZero asserts that i is not the zero value for its type.
+func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
+ if !assert.NotZero(t, i, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// NotZerof asserts that i is not the zero value for its type.
+func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) {
+ if !assert.NotZerof(t, i, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Panics asserts that the code inside the specified PanicTestFunc panics.
+//
+// assert.Panics(t, func(){ GoCrazy() })
+func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
+ if !assert.Panics(t, f, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
+// the recovered panic value equals the expected panic value.
+//
+// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
+func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
+ if !assert.PanicsWithValue(t, expected, f, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
+// the recovered panic value equals the expected panic value.
+//
+// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
+func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) {
+ if !assert.PanicsWithValuef(t, expected, f, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Panicsf asserts that the code inside the specified PanicTestFunc panics.
+//
+// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
+func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) {
+ if !assert.Panicsf(t, f, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Regexp asserts that a specified regexp matches a string.
+//
+// assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
+// assert.Regexp(t, "start...$", "it's not starting")
+func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
+ if !assert.Regexp(t, rx, str, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// Regexpf asserts that a specified regexp matches a string.
+//
+// assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
+// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
+func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) {
+ if !assert.Regexpf(t, rx, str, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Subset asserts that the specified list(array, slice...) contains all
+// elements given in the specified subset(array, slice...).
+//
+// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
+func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) {
+ if !assert.Subset(t, list, subset, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// Subsetf asserts that the specified list(array, slice...) contains all
+// elements given in the specified subset(array, slice...).
+//
+// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
+func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
+ if !assert.Subsetf(t, list, subset, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// True asserts that the specified value is true.
+//
+// assert.True(t, myBool)
+func True(t TestingT, value bool, msgAndArgs ...interface{}) {
+ if !assert.True(t, value, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// Truef asserts that the specified value is true.
+//
+// assert.Truef(t, myBool, "error message %s", "formatted")
+func Truef(t TestingT, value bool, msg string, args ...interface{}) {
+ if !assert.Truef(t, value, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// WithinDuration asserts that the two times are within duration delta of each other.
+//
+// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
+func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
+ if !assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// WithinDurationf asserts that the two times are within duration delta of each other.
+//
+// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
+func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) {
+ if !assert.WithinDurationf(t, expected, actual, delta, msg, args...) {
+ t.FailNow()
+ }
+}
+
+// Zero asserts that i is the zero value for its type.
+func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
+ if !assert.Zero(t, i, msgAndArgs...) {
+ t.FailNow()
+ }
+}
+
+// Zerof asserts that i is the zero value for its type.
+func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) {
+ if !assert.Zerof(t, i, msg, args...) {
+ t.FailNow()
+ }
+}
diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go b/vendor/github.com/stretchr/testify/require/require_forward.go
new file mode 100644
index 0000000000..299ceb95ad
--- /dev/null
+++ b/vendor/github.com/stretchr/testify/require/require_forward.go
@@ -0,0 +1,687 @@
+/*
+* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
+* THIS FILE MUST NOT BE EDITED BY HAND
+ */
+
+package require
+
+import (
+ assert "github.com/stretchr/testify/assert"
+ http "net/http"
+ url "net/url"
+ time "time"
+)
+
+// Condition uses a Comparison to assert a complex condition.
+func (a *Assertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}) {
+ Condition(a.t, comp, msgAndArgs...)
+}
+
+// Conditionf uses a Comparison to assert a complex condition.
+func (a *Assertions) Conditionf(comp assert.Comparison, msg string, args ...interface{}) {
+ Conditionf(a.t, comp, msg, args...)
+}
+
+// Contains asserts that the specified string, list(array, slice...) or map contains the
+// specified substring or element.
+//
+// a.Contains("Hello World", "World")
+// a.Contains(["Hello", "World"], "World")
+// a.Contains({"Hello": "World"}, "Hello")
+func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
+ Contains(a.t, s, contains, msgAndArgs...)
+}
+
+// Containsf asserts that the specified string, list(array, slice...) or map contains the
+// specified substring or element.
+//
+// a.Containsf("Hello World", "World", "error message %s", "formatted")
+// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted")
+// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted")
+func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) {
+ Containsf(a.t, s, contains, msg, args...)
+}
+
+// DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists.
+func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) {
+ DirExists(a.t, path, msgAndArgs...)
+}
+
+// DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists.
+func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) {
+ DirExistsf(a.t, path, msg, args...)
+}
+
+// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
+// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
+// the number of appearances of each of them in both lists should match.
+//
+// a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2])
+func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) {
+ ElementsMatch(a.t, listA, listB, msgAndArgs...)
+}
+
+// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
+// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
+// the number of appearances of each of them in both lists should match.
+//
+// a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
+func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) {
+ ElementsMatchf(a.t, listA, listB, msg, args...)
+}
+
+// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
+// a slice or a channel with len == 0.
+//
+// a.Empty(obj)
+func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) {
+ Empty(a.t, object, msgAndArgs...)
+}
+
+// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
+// a slice or a channel with len == 0.
+//
+// a.Emptyf(obj, "error message %s", "formatted")
+func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) {
+ Emptyf(a.t, object, msg, args...)
+}
+
+// Equal asserts that two objects are equal.
+//
+// a.Equal(123, 123)
+//
+// Pointer variable equality is determined based on the equality of the
+// referenced values (as opposed to the memory addresses). Function equality
+// cannot be determined and will always fail.
+func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
+ Equal(a.t, expected, actual, msgAndArgs...)
+}
+
+// EqualError asserts that a function returned an error (i.e. not `nil`)
+// and that it is equal to the provided error.
+//
+// actualObj, err := SomeFunction()
+// a.EqualError(err, expectedErrorString)
+func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) {
+ EqualError(a.t, theError, errString, msgAndArgs...)
+}
+
+// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
+// and that it is equal to the provided error.
+//
+// actualObj, err := SomeFunction()
+// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted")
+func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) {
+ EqualErrorf(a.t, theError, errString, msg, args...)
+}
+
+// EqualValues asserts that two objects are equal or convertable to the same types
+// and equal.
+//
+// a.EqualValues(uint32(123), int32(123))
+func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
+ EqualValues(a.t, expected, actual, msgAndArgs...)
+}
+
+// EqualValuesf asserts that two objects are equal or convertable to the same types
+// and equal.
+//
+// a.EqualValuesf(uint32(123, "error message %s", "formatted"), int32(123))
+func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
+ EqualValuesf(a.t, expected, actual, msg, args...)
+}
+
+// Equalf asserts that two objects are equal.
+//
+// a.Equalf(123, 123, "error message %s", "formatted")
+//
+// Pointer variable equality is determined based on the equality of the
+// referenced values (as opposed to the memory addresses). Function equality
+// cannot be determined and will always fail.
+func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
+ Equalf(a.t, expected, actual, msg, args...)
+}
+
+// Error asserts that a function returned an error (i.e. not `nil`).
+//
+// actualObj, err := SomeFunction()
+// if a.Error(err) {
+// assert.Equal(t, expectedError, err)
+// }
+func (a *Assertions) Error(err error, msgAndArgs ...interface{}) {
+ Error(a.t, err, msgAndArgs...)
+}
+
+// Errorf asserts that a function returned an error (i.e. not `nil`).
+//
+// actualObj, err := SomeFunction()
+// if a.Errorf(err, "error message %s", "formatted") {
+// assert.Equal(t, expectedErrorf, err)
+// }
+func (a *Assertions) Errorf(err error, msg string, args ...interface{}) {
+ Errorf(a.t, err, msg, args...)
+}
+
+// Exactly asserts that two objects are equal in value and type.
+//
+// a.Exactly(int32(123), int64(123))
+func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
+ Exactly(a.t, expected, actual, msgAndArgs...)
+}
+
+// Exactlyf asserts that two objects are equal in value and type.
+//
+// a.Exactlyf(int32(123, "error message %s", "formatted"), int64(123))
+func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
+ Exactlyf(a.t, expected, actual, msg, args...)
+}
+
+// Fail reports a failure through
+func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) {
+ Fail(a.t, failureMessage, msgAndArgs...)
+}
+
+// FailNow fails test
+func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) {
+ FailNow(a.t, failureMessage, msgAndArgs...)
+}
+
+// FailNowf fails test
+func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) {
+ FailNowf(a.t, failureMessage, msg, args...)
+}
+
+// Failf reports a failure through
+func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) {
+ Failf(a.t, failureMessage, msg, args...)
+}
+
+// False asserts that the specified value is false.
+//
+// a.False(myBool)
+func (a *Assertions) False(value bool, msgAndArgs ...interface{}) {
+ False(a.t, value, msgAndArgs...)
+}
+
+// Falsef asserts that the specified value is false.
+//
+// a.Falsef(myBool, "error message %s", "formatted")
+func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) {
+ Falsef(a.t, value, msg, args...)
+}
+
+// FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file.
+func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) {
+ FileExists(a.t, path, msgAndArgs...)
+}
+
+// FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file.
+func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) {
+ FileExistsf(a.t, path, msg, args...)
+}
+
+// HTTPBodyContains asserts that a specified handler returns a
+// body that contains a string.
+//
+// a.HTTPBodyContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
+//
+// Returns whether the assertion was successful (true) or not (false).
+func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
+ HTTPBodyContains(a.t, handler, method, url, values, str, msgAndArgs...)
+}
+
+// HTTPBodyContainsf asserts that a specified handler returns a
+// body that contains a string.
+//
+// a.HTTPBodyContainsf(myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
+//
+// Returns whether the assertion was successful (true) or not (false).
+func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
+ HTTPBodyContainsf(a.t, handler, method, url, values, str, msg, args...)
+}
+
+// HTTPBodyNotContains asserts that a specified handler returns a
+// body that does not contain a string.
+//
+// a.HTTPBodyNotContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
+//
+// Returns whether the assertion was successful (true) or not (false).
+func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
+ HTTPBodyNotContains(a.t, handler, method, url, values, str, msgAndArgs...)
+}
+
+// HTTPBodyNotContainsf asserts that a specified handler returns a
+// body that does not contain a string.
+//
+// a.HTTPBodyNotContainsf(myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
+//
+// Returns whether the assertion was successful (true) or not (false).
+func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
+ HTTPBodyNotContainsf(a.t, handler, method, url, values, str, msg, args...)
+}
+
+// HTTPError asserts that a specified handler returns an error status code.
+//
+// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
+//
+// Returns whether the assertion was successful (true) or not (false).
+func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
+ HTTPError(a.t, handler, method, url, values, msgAndArgs...)
+}
+
+// HTTPErrorf asserts that a specified handler returns an error status code.
+//
+// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
+//
+// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
+func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
+ HTTPErrorf(a.t, handler, method, url, values, msg, args...)
+}
+
+// HTTPRedirect asserts that a specified handler returns a redirect status code.
+//
+// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
+//
+// Returns whether the assertion was successful (true) or not (false).
+func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
+ HTTPRedirect(a.t, handler, method, url, values, msgAndArgs...)
+}
+
+// HTTPRedirectf asserts that a specified handler returns a redirect status code.
+//
+// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
+//
+// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
+func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
+ HTTPRedirectf(a.t, handler, method, url, values, msg, args...)
+}
+
+// HTTPSuccess asserts that a specified handler returns a success status code.
+//
+// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
+//
+// Returns whether the assertion was successful (true) or not (false).
+func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
+ HTTPSuccess(a.t, handler, method, url, values, msgAndArgs...)
+}
+
+// HTTPSuccessf asserts that a specified handler returns a success status code.
+//
+// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
+//
+// Returns whether the assertion was successful (true) or not (false).
+func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
+ HTTPSuccessf(a.t, handler, method, url, values, msg, args...)
+}
+
+// Implements asserts that an object is implemented by the specified interface.
+//
+// a.Implements((*MyInterface)(nil), new(MyObject))
+func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
+ Implements(a.t, interfaceObject, object, msgAndArgs...)
+}
+
+// Implementsf asserts that an object is implemented by the specified interface.
+//
+// a.Implementsf((*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
+func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
+ Implementsf(a.t, interfaceObject, object, msg, args...)
+}
+
+// InDelta asserts that the two numerals are within delta of each other.
+//
+// a.InDelta(math.Pi, (22 / 7.0), 0.01)
+func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
+ InDelta(a.t, expected, actual, delta, msgAndArgs...)
+}
+
+// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
+func (a *Assertions) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
+ InDeltaMapValues(a.t, expected, actual, delta, msgAndArgs...)
+}
+
+// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
+func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
+ InDeltaMapValuesf(a.t, expected, actual, delta, msg, args...)
+}
+
+// InDeltaSlice is the same as InDelta, except it compares two slices.
+func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
+ InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
+}
+
+// InDeltaSlicef is the same as InDelta, except it compares two slices.
+func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
+ InDeltaSlicef(a.t, expected, actual, delta, msg, args...)
+}
+
+// InDeltaf asserts that the two numerals are within delta of each other.
+//
+// a.InDeltaf(math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
+func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
+ InDeltaf(a.t, expected, actual, delta, msg, args...)
+}
+
+// InEpsilon asserts that expected and actual have a relative error less than epsilon
+func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
+ InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
+}
+
+// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
+func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
+ InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
+}
+
+// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
+func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
+ InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...)
+}
+
+// InEpsilonf asserts that expected and actual have a relative error less than epsilon
+func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
+ InEpsilonf(a.t, expected, actual, epsilon, msg, args...)
+}
+
+// IsType asserts that the specified objects are of the same type.
+func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
+ IsType(a.t, expectedType, object, msgAndArgs...)
+}
+
+// IsTypef asserts that the specified objects are of the same type.
+func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) {
+ IsTypef(a.t, expectedType, object, msg, args...)
+}
+
+// JSONEq asserts that two JSON strings are equivalent.
+//
+// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
+func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) {
+ JSONEq(a.t, expected, actual, msgAndArgs...)
+}
+
+// JSONEqf asserts that two JSON strings are equivalent.
+//
+// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
+func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) {
+ JSONEqf(a.t, expected, actual, msg, args...)
+}
+
+// Len asserts that the specified object has specific length.
+// Len also fails if the object has a type that len() not accept.
+//
+// a.Len(mySlice, 3)
+func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) {
+ Len(a.t, object, length, msgAndArgs...)
+}
+
+// Lenf asserts that the specified object has specific length.
+// Lenf also fails if the object has a type that len() not accept.
+//
+// a.Lenf(mySlice, 3, "error message %s", "formatted")
+func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) {
+ Lenf(a.t, object, length, msg, args...)
+}
+
+// Nil asserts that the specified object is nil.
+//
+// a.Nil(err)
+func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) {
+ Nil(a.t, object, msgAndArgs...)
+}
+
+// Nilf asserts that the specified object is nil.
+//
+// a.Nilf(err, "error message %s", "formatted")
+func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) {
+ Nilf(a.t, object, msg, args...)
+}
+
+// NoError asserts that a function returned no error (i.e. `nil`).
+//
+// actualObj, err := SomeFunction()
+// if a.NoError(err) {
+// assert.Equal(t, expectedObj, actualObj)
+// }
+func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) {
+ NoError(a.t, err, msgAndArgs...)
+}
+
+// NoErrorf asserts that a function returned no error (i.e. `nil`).
+//
+// actualObj, err := SomeFunction()
+// if a.NoErrorf(err, "error message %s", "formatted") {
+// assert.Equal(t, expectedObj, actualObj)
+// }
+func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) {
+ NoErrorf(a.t, err, msg, args...)
+}
+
+// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
+// specified substring or element.
+//
+// a.NotContains("Hello World", "Earth")
+// a.NotContains(["Hello", "World"], "Earth")
+// a.NotContains({"Hello": "World"}, "Earth")
+func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
+ NotContains(a.t, s, contains, msgAndArgs...)
+}
+
+// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
+// specified substring or element.
+//
+// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted")
+// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted")
+// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted")
+func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) {
+ NotContainsf(a.t, s, contains, msg, args...)
+}
+
+// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
+// a slice or a channel with len == 0.
+//
+// if a.NotEmpty(obj) {
+// assert.Equal(t, "two", obj[1])
+// }
+func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) {
+ NotEmpty(a.t, object, msgAndArgs...)
+}
+
+// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
+// a slice or a channel with len == 0.
+//
+// if a.NotEmptyf(obj, "error message %s", "formatted") {
+// assert.Equal(t, "two", obj[1])
+// }
+func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) {
+ NotEmptyf(a.t, object, msg, args...)
+}
+
+// NotEqual asserts that the specified values are NOT equal.
+//
+// a.NotEqual(obj1, obj2)
+//
+// Pointer variable equality is determined based on the equality of the
+// referenced values (as opposed to the memory addresses).
+func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
+ NotEqual(a.t, expected, actual, msgAndArgs...)
+}
+
+// NotEqualf asserts that the specified values are NOT equal.
+//
+// a.NotEqualf(obj1, obj2, "error message %s", "formatted")
+//
+// Pointer variable equality is determined based on the equality of the
+// referenced values (as opposed to the memory addresses).
+func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
+ NotEqualf(a.t, expected, actual, msg, args...)
+}
+
+// NotNil asserts that the specified object is not nil.
+//
+// a.NotNil(err)
+func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) {
+ NotNil(a.t, object, msgAndArgs...)
+}
+
+// NotNilf asserts that the specified object is not nil.
+//
+// a.NotNilf(err, "error message %s", "formatted")
+func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) {
+ NotNilf(a.t, object, msg, args...)
+}
+
+// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
+//
+// a.NotPanics(func(){ RemainCalm() })
+func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
+ NotPanics(a.t, f, msgAndArgs...)
+}
+
+// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
+//
+// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted")
+func (a *Assertions) NotPanicsf(f assert.PanicTestFunc, msg string, args ...interface{}) {
+ NotPanicsf(a.t, f, msg, args...)
+}
+
+// NotRegexp asserts that a specified regexp does not match a string.
+//
+// a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
+// a.NotRegexp("^start", "it's not starting")
+func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
+ NotRegexp(a.t, rx, str, msgAndArgs...)
+}
+
+// NotRegexpf asserts that a specified regexp does not match a string.
+//
+// a.NotRegexpf(regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
+// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted")
+func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) {
+ NotRegexpf(a.t, rx, str, msg, args...)
+}
+
+// NotSubset asserts that the specified list(array, slice...) contains not all
+// elements given in the specified subset(array, slice...).
+//
+// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
+func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) {
+ NotSubset(a.t, list, subset, msgAndArgs...)
+}
+
+// NotSubsetf asserts that the specified list(array, slice...) contains not all
+// elements given in the specified subset(array, slice...).
+//
+// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
+func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) {
+ NotSubsetf(a.t, list, subset, msg, args...)
+}
+
+// NotZero asserts that i is not the zero value for its type.
+func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) {
+ NotZero(a.t, i, msgAndArgs...)
+}
+
+// NotZerof asserts that i is not the zero value for its type.
+func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) {
+ NotZerof(a.t, i, msg, args...)
+}
+
+// Panics asserts that the code inside the specified PanicTestFunc panics.
+//
+// a.Panics(func(){ GoCrazy() })
+func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
+ Panics(a.t, f, msgAndArgs...)
+}
+
+// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
+// the recovered panic value equals the expected panic value.
+//
+// a.PanicsWithValue("crazy error", func(){ GoCrazy() })
+func (a *Assertions) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
+ PanicsWithValue(a.t, expected, f, msgAndArgs...)
+}
+
+// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
+// the recovered panic value equals the expected panic value.
+//
+// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
+func (a *Assertions) PanicsWithValuef(expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) {
+ PanicsWithValuef(a.t, expected, f, msg, args...)
+}
+
+// Panicsf asserts that the code inside the specified PanicTestFunc panics.
+//
+// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted")
+func (a *Assertions) Panicsf(f assert.PanicTestFunc, msg string, args ...interface{}) {
+ Panicsf(a.t, f, msg, args...)
+}
+
+// Regexp asserts that a specified regexp matches a string.
+//
+// a.Regexp(regexp.MustCompile("start"), "it's starting")
+// a.Regexp("start...$", "it's not starting")
+func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
+ Regexp(a.t, rx, str, msgAndArgs...)
+}
+
+// Regexpf asserts that a specified regexp matches a string.
+//
+// a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
+// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted")
+func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) {
+ Regexpf(a.t, rx, str, msg, args...)
+}
+
+// Subset asserts that the specified list(array, slice...) contains all
+// elements given in the specified subset(array, slice...).
+//
+// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
+func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) {
+ Subset(a.t, list, subset, msgAndArgs...)
+}
+
+// Subsetf asserts that the specified list(array, slice...) contains all
+// elements given in the specified subset(array, slice...).
+//
+// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
+func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) {
+ Subsetf(a.t, list, subset, msg, args...)
+}
+
+// True asserts that the specified value is true.
+//
+// a.True(myBool)
+func (a *Assertions) True(value bool, msgAndArgs ...interface{}) {
+ True(a.t, value, msgAndArgs...)
+}
+
+// Truef asserts that the specified value is true.
+//
+// a.Truef(myBool, "error message %s", "formatted")
+func (a *Assertions) Truef(value bool, msg string, args ...interface{}) {
+ Truef(a.t, value, msg, args...)
+}
+
+// WithinDuration asserts that the two times are within duration delta of each other.
+//
+// a.WithinDuration(time.Now(), time.Now(), 10*time.Second)
+func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
+ WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
+}
+
+// WithinDurationf asserts that the two times are within duration delta of each other.
+//
+// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
+func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) {
+ WithinDurationf(a.t, expected, actual, delta, msg, args...)
+}
+
+// Zero asserts that i is the zero value for its type.
+func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) {
+ Zero(a.t, i, msgAndArgs...)
+}
+
+// Zerof asserts that i is the zero value for its type.
+func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) {
+ Zerof(a.t, i, msg, args...)
+}
diff --git a/vendor/github.com/stretchr/testify/require/requirements.go b/vendor/github.com/stretchr/testify/require/requirements.go
new file mode 100644
index 0000000000..e404f016d1
--- /dev/null
+++ b/vendor/github.com/stretchr/testify/require/requirements.go
@@ -0,0 +1,9 @@
+package require
+
+// TestingT is an interface wrapper around *testing.T
+type TestingT interface {
+ Errorf(format string, args ...interface{})
+ FailNow()
+}
+
+//go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl -include-format-funcs