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.

client/remote_test.go +21

@@ -122,3 +122,24 @@ func TestGitSSHCommandCarriesThePolicy(t *testing.T) {
122 122 t.Fatal("GitSSHCommand modified the environment")
123 123 }
124 124 }
125
126 // TestRepoURLKeepsTheSSHUser: the user in an instance URL is the account sshd
127 // runs as. Vole's own listener ignored it, so dropping it was invisible; behind
128 // sshd a checkout without it asks for an account that cannot exist.
129 func TestRepoURLKeepsTheSSHUser(t *testing.T) {
130 t.Parallel()
131 for _, tc := range []struct{ remote, want string }{
132 {"ssh://git@forge.example.com", "ssh://git@forge.example.com/demo.git"},
133 {"ssh://git@forge.example.com:2222", "ssh://git@forge.example.com:2222/demo.git"},
134 {"ssh://git@forge.example.com/demo.git", "ssh://git@forge.example.com/demo.git"},
135 {"ssh://forge.example.com", "ssh://forge.example.com/demo.git"},
136 } {
137 got, err := RepoURL(tc.remote, "demo")
138 if err != nil {
139 t.Fatalf("RepoURL(%q) = %v", tc.remote, err)
140 }
141 if got != tc.want {
142 t.Errorf("RepoURL(%q) = %q, want %q", tc.remote, got, tc.want)
143 }
144 }
145 }