Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-05-20 11:27:34 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-05-23 10:23:14 +0300
commit116cab076a16e282518dbb73d4b2936bc0b4b7fc (patch)
tree429b35edaa7069b4df6b9bf50c067734ed197799
parent41fe00cab752de8701a0bc4f86866a30b9157d45 (diff)
linguist: Remove workaround to locate correct Git executablespks-linguist-gitconfig-clean
In the past we required a workaround for Linguist so that it picked up the correct Git executables. We have since converted the code to not use `git-linguist` anymore, but to use our own `gitaly-linguist` wrapper. And in fact, while `git-linguist` did use Git to verify that the repo exists, the Linguist Gem exclusively uses Rugged to access repos. As a consequence, `gitaly-linguist` doesn't use Git at all anymore. Remove the workaround to clean up the code. Note that we'd detect the case where we did unexpectedly execute Git here because we inject our own `PATH` in the testhelper code that has broken `git` wrappers in it. So if we did still execute it we'd see that tests failed.
-rw-r--r--internal/gitaly/linguist/linguist.go27
1 files changed, 1 insertions, 26 deletions
diff --git a/internal/gitaly/linguist/linguist.go b/internal/gitaly/linguist/linguist.go
index 39ac845c0..4ac9abfd2 100644
--- a/internal/gitaly/linguist/linguist.go
+++ b/internal/gitaly/linguist/linguist.go
@@ -92,32 +92,7 @@ func (inst *Instance) startGitLinguist(ctx context.Context, repoPath string, com
return nil, fmt.Errorf("finding bundle executable: %w", err)
}
- args := []string{
- bundle,
- "exec",
- "bin/gitaly-linguist",
- "--repository=" + repoPath,
- "--commit=" + commitID,
- }
-
- gitExecEnv := inst.gitCmdFactory.GetExecutionEnvironment(ctx)
-
- // This is a horrible hack. git-linguist will execute `git rev-parse
- // --git-dir` to check whether it is in a Git directory or not. We don't
- // want to use the one provided by PATH, but instead the one specified
- // via the configuration. git-linguist doesn't specify any way to choose
- // a different Git implementation, so we need to prepend the configured
- // Git's directory to PATH. But as our internal command interface will
- // overwrite PATH even if we pass it in here, we need to work around it
- // and instead execute the command with `env PATH=$GITDIR:$PATH`.
- gitDir := filepath.Dir(gitExecEnv.BinaryPath)
- if path, ok := os.LookupEnv("PATH"); ok && gitDir != "." {
- args = append([]string{
- "env", fmt.Sprintf("PATH=%s:%s", gitDir, path),
- }, args...)
- }
-
- cmd := exec.Command(args[0], args[1:]...)
+ cmd := exec.Command(bundle, "exec", "bin/gitaly-linguist", "--repository="+repoPath, "--commit="+commitID)
cmd.Dir = inst.cfg.Ruby.Dir
internalCmd, err := command.New(ctx, cmd, nil, nil, nil, env.AllowedRubyEnvironment(os.Environ())...)