forked from forgejo/forgejo
Use git log name-status in get last commit (#16059)
* Improve get last commit using git log --name-status git log --name-status -c provides information about the diff between a commit and its parents. Using this and adjusting the algorithm to use the first change to a path allows for a much faster generation of commit info. There is a subtle change in the results generated but this will cause the results to more closely match those from elsewhere. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
8fa3bbc424
commit
23358bc55d
40 changed files with 2540 additions and 297 deletions
22
vendor/github.com/djherbis/nio/v3/.travis.yml
generated
vendored
Normal file
22
vendor/github.com/djherbis/nio/v3/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
language: go
|
||||
go:
|
||||
- tip
|
||||
before_install:
|
||||
- go get -u golang.org/x/lint/golint
|
||||
- go get github.com/axw/gocov/gocov
|
||||
- go get github.com/mattn/goveralls
|
||||
- if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover;
|
||||
fi
|
||||
script:
|
||||
- '[ "${TRAVIS_PULL_REQUEST}" != "false" ] || $HOME/gopath/bin/goveralls -service=travis-ci
|
||||
-repotoken $COVERALLS_TOKEN'
|
||||
- "$HOME/gopath/bin/golint ./..."
|
||||
- go vet
|
||||
- go test -bench=.* -v ./...
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
on_failure: change
|
||||
env:
|
||||
global:
|
||||
secure: gpKsimMN5YScLnbcoWvJPw8VL+qCpZgnC4i8mFn/lRX5Ta9FhDMROQre0Ko4bU9RX/u/IBL1fO/IyaVtVWQ0fhsDi+ovrh3LgzewwZBgz7FGiyFpagvf91Jwq5Yus15QQZ8MebrQ41H1YiWMdLOHlZdN6gNb0cswg3w4MRjbGb4=
|
20
vendor/github.com/djherbis/nio/v3/LICENSE.txt
generated
vendored
Normal file
20
vendor/github.com/djherbis/nio/v3/LICENSE.txt
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Dustin H
|
||||
|
||||
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.
|
65
vendor/github.com/djherbis/nio/v3/README.md
generated
vendored
Normal file
65
vendor/github.com/djherbis/nio/v3/README.md
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
nio
|
||||
==========
|
||||
|
||||
[](https://godoc.org/github.com/djherbis/nio)
|
||||
[](https://github.com/djherbis/nio/releases/latest)
|
||||
[](LICENSE.txt)
|
||||
[](https://travis-ci.org/djherbis/nio)
|
||||
[](https://coveralls.io/r/djherbis/nio?branch=master)
|
||||
[](https://goreportcard.com/report/github.com/djherbis/nio)
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
The Buffer interface:
|
||||
|
||||
```go
|
||||
type Buffer interface {
|
||||
Len() int64
|
||||
Cap() int64
|
||||
io.ReadWriter
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
nio's Copy method concurrently copies from an io.Reader to a supplied nio.Buffer,
|
||||
then from the nio.Buffer to an io.Writer. This way, blocking writes don't slow the io.Reader.
|
||||
|
||||
```go
|
||||
import (
|
||||
"github.com/djherbis/buffer"
|
||||
"github.com/djherbis/nio"
|
||||
)
|
||||
|
||||
buf := buffer.New(32*1024) // 32KB In memory Buffer
|
||||
nio.Copy(w, r, buf) // Reads and Writes concurrently, buffering using buf.
|
||||
```
|
||||
|
||||
nio's Pipe method is a buffered version of io.Pipe
|
||||
The writer return once its data has been written to the Buffer.
|
||||
The reader returns with data off the Buffer.
|
||||
|
||||
```go
|
||||
import (
|
||||
"gopkg.in/djherbis/buffer.v1"
|
||||
"gopkg.in/djherbis/nio.v2"
|
||||
)
|
||||
|
||||
buf := buffer.New(32*1024) // 32KB In memory Buffer
|
||||
r, w := nio.Pipe(buf)
|
||||
```
|
||||
|
||||
Installation
|
||||
------------
|
||||
```sh
|
||||
go get gopkg.in/djherbis/nio.v2
|
||||
```
|
||||
|
||||
For some pre-built buffers grab:
|
||||
```sh
|
||||
go get gopkg.in/djherbis/buffer.v1
|
||||
```
|
||||
|
||||
Mentions
|
||||
------------
|
||||
[GopherCon 2017: Peter Bourgon - Evolutionary Optimization with Go](https://www.youtube.com/watch?v=ha8gdZ27wMo&start=2077&end=2140)
|
5
vendor/github.com/djherbis/nio/v3/go.mod
generated
vendored
Normal file
5
vendor/github.com/djherbis/nio/v3/go.mod
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
module github.com/djherbis/nio/v3
|
||||
|
||||
go 1.16
|
||||
|
||||
require github.com/djherbis/buffer v1.1.0
|
2
vendor/github.com/djherbis/nio/v3/go.sum
generated
vendored
Normal file
2
vendor/github.com/djherbis/nio/v3/go.sum
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
github.com/djherbis/buffer v1.1.0 h1:uGQ+DZDAMlfC2z3khbBtLcAHC0wyoNrX9lpOml3g3fg=
|
||||
github.com/djherbis/buffer v1.1.0/go.mod h1:VwN8VdFkMY0DCALdY8o00d3IZ6Amz/UNVMWcSaJT44o=
|
53
vendor/github.com/djherbis/nio/v3/nio.go
generated
vendored
Normal file
53
vendor/github.com/djherbis/nio/v3/nio.go
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Package nio provides a few buffered io primitives.
|
||||
package nio
|
||||
|
||||
import "io"
|
||||
|
||||
// Buffer is used to store bytes.
|
||||
type Buffer interface {
|
||||
// Len returns how many bytes are buffered
|
||||
Len() int64
|
||||
|
||||
// Cap returns how many bytes can in the buffer at a time
|
||||
Cap() int64
|
||||
|
||||
// ReadWriter writes are stored in the buffer, reads return the stored data
|
||||
io.ReadWriter
|
||||
}
|
||||
|
||||
// Pipe creates a buffered pipe.
|
||||
// It can be used to connect code expecting an io.Reader with code expecting an io.Writer.
|
||||
// Reads on one end read from the supplied Buffer. Writes write to the supplied Buffer.
|
||||
// It is safe to call Read and Write in parallel with each other or with Close.
|
||||
// Close will complete once pending I/O is done, and may cancel blocking Read/Writes.
|
||||
// Buffered data will still be available to Read after the Writer has been closed.
|
||||
// Parallel calls to Read, and parallel calls to Write are also safe :
|
||||
// the individual calls will be gated sequentially.
|
||||
func Pipe(buf Buffer) (r *PipeReader, w *PipeWriter) {
|
||||
p := newBufferedPipe(buf)
|
||||
r = &PipeReader{bufpipe: p}
|
||||
w = &PipeWriter{bufpipe: p}
|
||||
return r, w
|
||||
}
|
||||
|
||||
// Copy copies from src to buf, and from buf to dst in parallel until
|
||||
// either EOF is reached on src or an error occurs. It returns the number of bytes
|
||||
// copied to dst and the first error encountered while copying, if any.
|
||||
// EOF is not considered to be an error. If src implements WriterTo, it is used to
|
||||
// write to the supplied Buffer. If dst implements ReaderFrom, it is used to read from
|
||||
// the supplied Buffer.
|
||||
func Copy(dst io.Writer, src io.Reader, buf Buffer) (n int64, err error) {
|
||||
return io.Copy(dst, NewReader(src, buf))
|
||||
}
|
||||
|
||||
// NewReader reads from the buffer which is concurrently filled with data from the passed src.
|
||||
func NewReader(src io.Reader, buf Buffer) io.ReadCloser {
|
||||
r, w := Pipe(buf)
|
||||
|
||||
go func() {
|
||||
_, err := io.Copy(w, src)
|
||||
w.CloseWithError(err)
|
||||
}()
|
||||
|
||||
return r
|
||||
}
|
177
vendor/github.com/djherbis/nio/v3/sync.go
generated
vendored
Normal file
177
vendor/github.com/djherbis/nio/v3/sync.go
generated
vendored
Normal file
|
@ -0,0 +1,177 @@
|
|||
package nio
|
||||
|
||||
import (
|
||||
"io"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// PipeReader is the read half of the pipe.
|
||||
type PipeReader struct {
|
||||
*bufpipe
|
||||
}
|
||||
|
||||
// CloseWithError closes the reader; subsequent writes to the write half of the pipe will return the error err.
|
||||
func (r *PipeReader) CloseWithError(err error) error {
|
||||
if err == nil {
|
||||
err = io.ErrClosedPipe
|
||||
}
|
||||
r.bufpipe.l.Lock()
|
||||
defer r.bufpipe.l.Unlock()
|
||||
if r.bufpipe.rerr == nil {
|
||||
r.bufpipe.rerr = err
|
||||
r.bufpipe.rwait.Signal()
|
||||
r.bufpipe.wwait.Signal()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close closes the reader; subsequent writes to the write half of the pipe will return the error io.ErrClosedPipe.
|
||||
func (r *PipeReader) Close() error {
|
||||
return r.CloseWithError(nil)
|
||||
}
|
||||
|
||||
// A PipeWriter is the write half of a pipe.
|
||||
type PipeWriter struct {
|
||||
*bufpipe
|
||||
}
|
||||
|
||||
// CloseWithError closes the writer; once the buffer is empty subsequent reads from the read half of the pipe will return
|
||||
// no bytes and the error err, or io.EOF if err is nil. CloseWithError always returns nil.
|
||||
func (w *PipeWriter) CloseWithError(err error) error {
|
||||
if err == nil {
|
||||
err = io.EOF
|
||||
}
|
||||
w.bufpipe.l.Lock()
|
||||
defer w.bufpipe.l.Unlock()
|
||||
if w.bufpipe.werr == nil {
|
||||
w.bufpipe.werr = err
|
||||
w.bufpipe.rwait.Signal()
|
||||
w.bufpipe.wwait.Signal()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close closes the writer; once the buffer is empty subsequent reads from the read half of the pipe will return
|
||||
// no bytes and io.EOF after all the buffer has been read. CloseWithError always returns nil.
|
||||
func (w *PipeWriter) Close() error {
|
||||
return w.CloseWithError(nil)
|
||||
}
|
||||
|
||||
type bufpipe struct {
|
||||
rl sync.Mutex
|
||||
wl sync.Mutex
|
||||
l sync.Mutex
|
||||
rwait sync.Cond
|
||||
wwait sync.Cond
|
||||
b Buffer
|
||||
rerr error // if reader closed, error to give writes
|
||||
werr error // if writer closed, error to give reads
|
||||
}
|
||||
|
||||
func newBufferedPipe(buf Buffer) *bufpipe {
|
||||
s := &bufpipe{
|
||||
b: buf,
|
||||
}
|
||||
s.rwait.L = &s.l
|
||||
s.wwait.L = &s.l
|
||||
return s
|
||||
}
|
||||
|
||||
func empty(buf Buffer) bool {
|
||||
return buf.Len() == 0
|
||||
}
|
||||
|
||||
func gap(buf Buffer) int64 {
|
||||
return buf.Cap() - buf.Len()
|
||||
}
|
||||
|
||||
func (r *PipeReader) Read(p []byte) (n int, err error) {
|
||||
r.rl.Lock()
|
||||
defer r.rl.Unlock()
|
||||
|
||||
r.l.Lock()
|
||||
defer r.wwait.Signal()
|
||||
defer r.l.Unlock()
|
||||
|
||||
for empty(r.b) {
|
||||
if r.rerr != nil {
|
||||
return 0, io.ErrClosedPipe
|
||||
}
|
||||
|
||||
if r.werr != nil {
|
||||
return 0, r.werr
|
||||
}
|
||||
|
||||
r.wwait.Signal()
|
||||
r.rwait.Wait()
|
||||
}
|
||||
|
||||
n, err = r.b.Read(p)
|
||||
if err == io.EOF {
|
||||
err = nil
|
||||
}
|
||||
|
||||
return n, err
|
||||
}
|
||||
|
||||
func (w *PipeWriter) Write(p []byte) (int, error) {
|
||||
var m int
|
||||
var n, space int64
|
||||
var err error
|
||||
sliceLen := int64(len(p))
|
||||
|
||||
w.wl.Lock()
|
||||
defer w.wl.Unlock()
|
||||
|
||||
w.l.Lock()
|
||||
defer w.rwait.Signal()
|
||||
defer w.l.Unlock()
|
||||
|
||||
if w.werr != nil {
|
||||
return 0, io.ErrClosedPipe
|
||||
}
|
||||
|
||||
// while there is data to write
|
||||
for writeLen := sliceLen; writeLen > 0 && err == nil; writeLen = sliceLen - n {
|
||||
|
||||
// wait for some buffer space to become available (while no errs)
|
||||
for space = gap(w.b); space == 0 && w.rerr == nil && w.werr == nil; space = gap(w.b) {
|
||||
w.rwait.Signal()
|
||||
w.wwait.Wait()
|
||||
}
|
||||
|
||||
if w.rerr != nil {
|
||||
err = w.rerr
|
||||
break
|
||||
}
|
||||
|
||||
if w.werr != nil {
|
||||
err = io.ErrClosedPipe
|
||||
break
|
||||
}
|
||||
|
||||
// space > 0, and locked
|
||||
|
||||
var nn int64
|
||||
if space < writeLen {
|
||||
// => writeLen - space > 0
|
||||
// => (sliceLen - n) - space > 0
|
||||
// => sliceLen > n + space
|
||||
// nn is safe to use for p[:nn]
|
||||
nn = n + space
|
||||
} else {
|
||||
nn = sliceLen
|
||||
}
|
||||
|
||||
m, err = w.b.Write(p[n:nn])
|
||||
n += int64(m)
|
||||
|
||||
// one of the following cases has occurred:
|
||||
// 1. done writing -> writeLen == 0
|
||||
// 2. ran out of buffer space -> gap(w.b) == 0
|
||||
// 3. an error occurred err != nil
|
||||
// all of these cases are handled at the top of this loop
|
||||
}
|
||||
|
||||
return int(n), err
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue