Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Make a job checkout follow the remote it was told to use

5baf4e736be8096457f877f5e8b18f73404ed5c5 · Keenan Nemetz · 16d ago · parent 8a4af42e

Make a job checkout follow the remote it was told to use

Two defects, one incident: the forge moved behind sshd and CI could not check
out a commit.

A cached checkout kept the clone URL it was born with. prepareWorktree clones
once and afterwards only fetches from origin, so changing --remote — a new port,
a new host, the front door replacing Vole's own listener — left every job
fetching an address that no longer exists. It now points origin at the URL built
from the current argument before fetching, so the cache follows the runner's
configuration rather than the day it was created.

client.RepoURL dropped the user from the instance URL. Vole's own listener
authenticates the key and ignores the name the client asks for, so that was
invisible; sshd selects the operating-system account by that name, and a checkout
without it asks for an account that cannot exist. The user is kept (the name
only: a password has no meaning over SSH and must not be copied into a URL).

The worktree test never changed the remote, and RepoURL had no test at all, so
both are covered now: a second prepareWorktree with a different remote asserts
origin moved, and RepoURL is checked with and without a user and a port.

Closes #316.

ci/agent/worktree_test.go +13

@@ -126,6 +126,19 @@ func TestPrepareWorktreeSeparatesTrustedCacheFromJobTree(t *testing.T) {
126 126 if got := strings.TrimSpace(mustGit(t, again.Work, "rev-parse", "HEAD")); got != sha {
127 127 t.Fatalf("the second job tree is at %s, want %s", got, sha)
128 128 }
129
130 // The cache outlives --remote. A runner told to use a different instance must
131 // follow it, or the checkout keeps fetching from an address that may not exist
132 // any more — which is what happened when the forge moved behind sshd.
133 moved, err := prepareWorktree("ssh://git@elsewhere.invalid", cache, "demo", sha, "run3", 1)
134 if err != nil {
135 t.Fatalf("prepareWorktree after changing the remote: %v", err)
136 }
137 defer moved.cleanup()
138 if got, want := strings.TrimSpace(mustGit(t, filepath.Join(cache, "demo"), "remote", "get-url", "origin")),
139 "ssh://git@elsewhere.invalid/demo.git"; got != want {
140 t.Fatalf("the cache still points at %s, want %s", got, want)
141 }
129 142 }
130 143
131 144 func sshCalls(t *testing.T, path string) int {