mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-04 16:04:07 +00:00
ad38b60983
Removes the go-git backend so every build uses the git CLI backend. Its Windows performance advantage is gone, it lacks SHA-256 support, and it breaks repositories on Windows. The performance changes moved to https://github.com/go-gitea/gitea/pull/39526. Fixes https://github.com/go-gitea/gitea/issues/38359 Fixes https://github.com/go-gitea/gitea/issues/34694 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package pipeline
|
|
|
|
import (
|
|
"bufio"
|
|
"context"
|
|
"errors"
|
|
"strings"
|
|
|
|
"gitea.dev/modules/git"
|
|
"gitea.dev/modules/git/gitcmd"
|
|
|
|
"golang.org/x/sync/errgroup"
|
|
)
|
|
|
|
func fillResultNameRev(ctx context.Context, repo git.RepositoryFacade, results []*LFSResult) error {
|
|
wg := errgroup.Group{}
|
|
cmd := gitcmd.NewCommand("name-rev", "--stdin", "--name-only", "--always").WithRepo(repo)
|
|
stdin, stdinClose := cmd.MakeStdinPipe()
|
|
stdout, stdoutClose := cmd.MakeStdoutPipe()
|
|
defer stdinClose()
|
|
defer stdoutClose()
|
|
|
|
wg.Go(func() error {
|
|
scanner := bufio.NewScanner(stdout)
|
|
i := 0
|
|
for scanner.Scan() {
|
|
line := scanner.Text()
|
|
if len(line) == 0 {
|
|
continue
|
|
}
|
|
result := results[i]
|
|
result.FullCommitName = line
|
|
result.BranchName = strings.Split(line, "~")[0]
|
|
i++
|
|
}
|
|
return scanner.Err()
|
|
})
|
|
wg.Go(func() error {
|
|
defer stdinClose()
|
|
for _, result := range results {
|
|
_, err := stdin.Write([]byte(result.SHA))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = stdin.Write([]byte{'\n'})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
})
|
|
err := cmd.RunWithStderr(ctx)
|
|
return errors.Join(err, wg.Wait())
|
|
}
|