1
0
Fork 0
forked from forgejo/forgejo

Delete old git.NewCommand() and use it as git.NewCommandContext() (#18552)

This commit is contained in:
6543 2022-02-06 20:01:47 +01:00 committed by GitHub
parent 8ae5e6d7fd
commit 3043eb36bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
74 changed files with 258 additions and 263 deletions

View file

@ -29,7 +29,7 @@ type repoChanges struct {
}
func getDefaultBranchSha(ctx context.Context, repo *repo_model.Repository) (string, error) {
stdout, err := git.NewCommandContext(ctx, "show-ref", "-s", git.BranchPrefix+repo.DefaultBranch).RunInDir(repo.RepoPath())
stdout, err := git.NewCommand(ctx, "show-ref", "-s", git.BranchPrefix+repo.DefaultBranch).RunInDir(repo.RepoPath())
if err != nil {
return "", err
}
@ -92,7 +92,7 @@ func parseGitLsTreeOutput(stdout []byte) ([]fileUpdate, error) {
// genesisChanges get changes to add repo to the indexer for the first time
func genesisChanges(ctx context.Context, repo *repo_model.Repository, revision string) (*repoChanges, error) {
var changes repoChanges
stdout, err := git.NewCommandContext(ctx, "ls-tree", "--full-tree", "-l", "-r", revision).
stdout, err := git.NewCommand(ctx, "ls-tree", "--full-tree", "-l", "-r", revision).
RunInDirBytes(repo.RepoPath())
if err != nil {
return nil, err
@ -103,7 +103,7 @@ func genesisChanges(ctx context.Context, repo *repo_model.Repository, revision s
// nonGenesisChanges get changes since the previous indexer update
func nonGenesisChanges(ctx context.Context, repo *repo_model.Repository, revision string) (*repoChanges, error) {
diffCmd := git.NewCommandContext(ctx, "diff", "--name-status",
diffCmd := git.NewCommand(ctx, "diff", "--name-status",
repo.CodeIndexerStatus.CommitSha, revision)
stdout, err := diffCmd.RunInDir(repo.RepoPath())
if err != nil {
@ -167,7 +167,7 @@ func nonGenesisChanges(ctx context.Context, repo *repo_model.Repository, revisio
}
}
cmd := git.NewCommandContext(ctx, "ls-tree", "--full-tree", "-l", revision, "--")
cmd := git.NewCommand(ctx, "ls-tree", "--full-tree", "-l", revision, "--")
cmd.AddArguments(updatedFilenames...)
lsTreeStdout, err := cmd.RunInDirBytes(repo.RepoPath())
if err != nil {