c572fcfe04
Rename the Go module path from code.gitea.io/gitea to git.mokoconsulting.tech/MokoConsulting/MokoGitea across the entire codebase. Scope: - go.mod module declaration - 2,235 Go source files (import paths) - Dockerfile WORKDIR and COPY paths - Swagger API templates - golangci.yml linter config External dependencies (code.gitea.io/gitea-vet, code.gitea.io/sdk/gitea, gitea.com/gitea/act, etc.) are intentionally NOT renamed — they are separate upstream modules. Closes #132 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package pipeline
|
|
|
|
import (
|
|
"bufio"
|
|
"context"
|
|
"errors"
|
|
"strings"
|
|
|
|
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/git/gitcmd"
|
|
|
|
"golang.org/x/sync/errgroup"
|
|
)
|
|
|
|
func fillResultNameRev(ctx context.Context, basePath string, results []*LFSResult) error {
|
|
// Should really use a go-git function here but name-rev is not completed and recapitulating it is not simple
|
|
wg := errgroup.Group{}
|
|
cmd := gitcmd.NewCommand("name-rev", "--stdin", "--name-only", "--always").WithDir(basePath)
|
|
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())
|
|
}
|