--- title: "ADR 0004: How PAC shells out to git" --- * Status: accepted * Code: [`pkg/git/git.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/git/git.go), `RunGit`, `GetGitInfo` ## Context PAC runs `git` from the controller process (`RunGit`) to read the local checkout, mostly to discover the origin remote for a payload that lacks a URL (`GetGitInfo`). Three things make the invocation less obvious than `exec.Command`: * the process runs with a stripped environment (`PATH`, `HOME`, `LC_ALL=C`, `LANG=C`), so a user's git config is not available by design, and command output stays parseable regardless of the caller's locale * on a developer machine `commit.gpgsign=true` is common, and a signing prompt would hang the controller forever with no terminal * remotes are frequently SSH (`git@host:org/repo.git`) while everything downstream expects an https URL ## Decision * Every invocation is prefixed with `-c commit.gpgsign=false`, so a repository-level or global signing setting cannot block it. * The environment is reduced to `PATH`, `HOME`, `LC_ALL=C` and `LANG=C` instead of inheriting the parent's, which also pins the locale of every message this code parses. * `GetGitInfo` falls back to the top-level directory name when no remote is configured, rather than returning an empty URL. * SSH remotes are rewritten to https by replacing the `git@` prefix and joining the path with `/`: `git@github.com:org/repo` becomes `https://github.com/org/repo`. ## Consequences * Signing or credential helpers that need a TTY are never invoked. That is the point, but it also means a repository that refuses unsigned work cannot be read through this path. * The SSH rewrite is textual and assumes the `git@host:path` shape. Remote helpers with credentials in the URL, or exotic SSH configs, are not handled, and Bitbucket Data Center is the known case where the rewrite produces a URL the installer does not expect. * `GetGitInfo` never fails: a missing remote, or no git binary at all, yields an empty or directory-derived URL and the caller proceeds with a less accurate repository name.