Skip to content
repos, git-credential

repos, git-credential

Every organization has its own git service: one repository per project, one of your own (home), and the organization’s own repositories. Git: your org’s repositories shows how to use it; this page is the commands.

space repos list

space repos list
space repos

Name, kind (project, free or home), access and clone URL of the repositories your API key can use: the repository of each project it reaches (with --project or a project in use, only that one’s), the organization’s repositories it reaches (free, whichever project is in use: every one with a key of All projects, the ones shared with one of its projects with a key of selected projects), and your own. Access is read-write, or read-only with a read-only key and for an organization’s repository someone else made. With -q, only the names; with --json, the portal’s answer, which also has each repository’s web address (web_url), its address inside a machine (machine_url) and the git host (git_url).

NAME        KIND     ACCESS      CLONE URL
web         project  read-write  https://git.lab.agent-spaces.eu/acme/web.git
shared-lib  free     read-only   https://git.lab.agent-spaces.eu/acme/shared-lib.git
home        home     read-write  https://git.lab.agent-spaces.eu/~/home.git

While git has no credential helper for these URLs, the command says so on stderr. Exits 4 when the organization’s region has no git service.

space repos setup

space repos setup

Makes git ask space for a credential whenever it talks to your org’s git host, by writing these lines into your global git config (~/.gitconfig):

[credential "https://git.lab.agent-spaces.eu"]
	helper =
	helper = !space git-credential
	useHttpPath = true

The empty first line stops your other credential helpers (a keychain, store) from answering for this host or keeping its short-lived credential. useHttpPath makes git send the repository’s path, so space git-credential can pick the profile whose API key sees that repository. The helper names no profile: one setup covers every profile, and it writes these lines for the git host of each profile’s portal. The profile in use (the default, or the one named with --profile) must reach its portal, or setup fails: name a reachable one with --profile. The other profiles’ portals are asked too, and one that can’t be reached is skipped. With AGENTSPACES_API_KEY set, only the profile in use is asked: that key is for its portal alone. A portal named with --url goes into the helper (!space --url <portal> git-credential), so git asks that portal later, and only its git host gets the lines. Running it again changes nothing. It prints what it wrote and a git clone to try. Needs git and space on your PATH.

space git-credential

space git-credential <get|store|erase>

git’s credential helper; git runs it for you once space repos setup has configured it. It speaks git’s protocol: the request as key=value lines on stdin, the answer on stdout.

  • get: for your org’s git host, answers with a credential from the portal: user name space and a token that lasts one hour, from the profile whose key sees the repository (below). The token reaches every repository space repos lists, the organization’s too (pushing only to the ones you made), and one is kept for all of them. With an old key of one project it is that project’s repository and your own. A read-only key gives a token that can clone and fetch but not push. For any other host, or anything but https, it prints nothing, so git asks its other helpers. Plain http is answered only for localhost, 127.0.0.1 and [::1] (a local dev setup); to any other host it says so on stderr and answers nothing, since the token would travel unencrypted.
  • store: does nothing.
  • erase: forgets the kept credentials for the host (each profile’s), so the next get asks the portal again. git calls it when the server refused a credential.

Which profile answers: the one named with --profile or AGENTSPACES_PROFILE, or the key in AGENTSPACES_API_KEY; with --url, the profile in use. Otherwise, when git sends the repository’s path (useHttpPath, which setup turns on) and more than one profile has a key, get asks the portal of each profile for the repositories its key sees, every time (the list isn’t kept), and uses the profile that sees this one. Only the profiles whose org lives on this git host take part. When several see it (your own home) or none does, the default profile answers if it takes part, else the first of them by name. Without the path, the default profile does.

The credential is kept in ~/.cache/agentspaces/ (AGENTSPACES_CACHE_DIR, else XDG_CACHE_HOME), in a file only you can read, and used again until five minutes before it ends. A kept file that others can read (after a chmod, say) is not used: get removes it, says so on stderr and asks the portal for a new token. It is never printed anywhere else, also not with --verbose.

When something is wrong (no API key, the portal can’t be reached), it says so on stderr and still exits 0 with no answer: git then asks you for a user name and password, which this git service doesn’t have. Fix the cause (space login) and try again.

To see what git would get:

printf 'protocol=https\nhost=git.lab.agent-spaces.eu\n\n' | space git-credential get
Last updated on