feat: vendor gitea 1.16.2

This commit is contained in:
2026-06-02 08:36:01 +00:00
parent 247cd60f69
commit 54798b4615
2145 changed files with 162965 additions and 126447 deletions
@@ -6,9 +6,6 @@ package gitgraph
import (
"bufio"
"bytes"
"context"
"os"
"strings"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/git/gitcmd"
@@ -45,22 +42,14 @@ func GetCommitGraph(r *git.Repository, page, maxAllowedColors int, hidePRRefs bo
}
graph := NewGraph()
stderr := new(strings.Builder)
stdoutReader, stdoutWriter, err := os.Pipe()
if err != nil {
return nil, err
}
commitsToSkip := setting.UI.GraphMaxCommitNum * (page - 1)
scanner := bufio.NewScanner(stdoutReader)
if err := graphCmd.Run(r.Ctx, &gitcmd.RunOpts{
Dir: r.Path,
Stdout: stdoutWriter,
Stderr: stderr,
PipelineFunc: func(ctx context.Context, cancel context.CancelFunc) error {
_ = stdoutWriter.Close()
defer stdoutReader.Close()
stdoutReader, stdoutReaderClose := graphCmd.MakeStdoutPipe()
defer stdoutReaderClose()
if err := graphCmd.
WithDir(r.Path).
WithPipelineFunc(func(ctx gitcmd.Context) error {
scanner := bufio.NewScanner(stdoutReader)
parser := &Parser{}
parser.firstInUse = -1
parser.maxAllowedColors = maxAllowedColors
@@ -92,8 +81,7 @@ func GetCommitGraph(r *git.Repository, page, maxAllowedColors int, hidePRRefs bo
line := scanner.Bytes()
if bytes.IndexByte(line, '*') >= 0 {
if err := parser.AddLineToGraph(graph, row, line); err != nil {
cancel()
return err
return ctx.CancelPipeline(err)
}
break
}
@@ -104,13 +92,12 @@ func GetCommitGraph(r *git.Repository, page, maxAllowedColors int, hidePRRefs bo
row++
line := scanner.Bytes()
if err := parser.AddLineToGraph(graph, row, line); err != nil {
cancel()
return err
return ctx.CancelPipeline(err)
}
}
return scanner.Err()
},
}); err != nil {
}).
RunWithStderr(r.Ctx); err != nil {
return graph, err
}
return graph, nil
@@ -238,8 +238,8 @@ func TestCommitStringParsing(t *testing.T) {
for _, test := range tests {
t.Run(test.testName, func(t *testing.T) {
testString := fmt.Sprintf("%s%s", dataFirstPart, test.commitMessage)
idx := strings.Index(testString, "DATA:")
commit, err := NewCommit(0, 0, []byte(testString[idx+5:]))
_, after, _ := strings.Cut(testString, "DATA:")
commit, err := NewCommit(0, 0, []byte(after))
if err != nil && test.shouldPass {
t.Errorf("Could not parse %s", testString)
return
@@ -44,11 +44,11 @@ func (parser *Parser) Reset() {
// AddLineToGraph adds the line as a row to the graph
func (parser *Parser) AddLineToGraph(graph *Graph, row int, line []byte) error {
idx := bytes.Index(line, []byte("DATA:"))
if idx < 0 {
before, after, ok := bytes.Cut(line, []byte("DATA:"))
if !ok {
parser.ParseGlyphs(line)
} else {
parser.ParseGlyphs(line[:idx])
parser.ParseGlyphs(before)
}
var err error
@@ -72,7 +72,7 @@ func (parser *Parser) AddLineToGraph(graph *Graph, row int, line []byte) error {
}
}
commitDone = true
if idx < 0 {
if !ok {
if err != nil {
err = fmt.Errorf("missing data section on line %d with commit: %s. %w", row, string(line), err)
} else {
@@ -80,7 +80,7 @@ func (parser *Parser) AddLineToGraph(graph *Graph, row int, line []byte) error {
}
continue
}
err2 := graph.AddCommit(row, column, flowID, line[idx+5:])
err2 := graph.AddCommit(row, column, flowID, after)
if err != nil && err2 != nil {
err = fmt.Errorf("%v %w", err2, err)
continue