Fix cloning steps when branch ref contains a forward slash

Problem

Step-runner fails to clone steps when the branch ref contains a forward slash (e.g., feature/test00):

Error: failed to run steps: step "step00": failed to load: fetching git step: storing SHA for ref "feature/test00": open /tmp/step-runner-cache/.../. refs/feature/test00.sha: no such file or directory

Root cause

storeSHAForRef created only the .refs/ directory, but when the ref contains a /, the resulting file path includes intermediate directories (.refs/feature/) that were never created.

Fix

Compute the full file path first, then derive the directory from it using filepath.Dir. This ensures MkdirAll creates the complete directory tree for any ref, regardless of how many / segments it contains. For simple
refs like main, the behavior is unchanged.

How to test the change

With old binary

> ./step-runner run --git-url gitlab-ci-token:${GITLAB_TOKEN}@gitlab.com/ra-group2/ra-step --git-rev ra/test --git-dir steps/dummy --inputs project_name=HelloWindows
Error: step "step": failed to load: fetching git func: storing SHA for ref "ra/test": open /var/folders/jj/dlc3v6n9757c12s9z1f9fsgw0000gn/T/step-runner-cache/gitlab.com/ra-group2/ra-step/.refs/ra/test.sha: no such file or directory

With new binary

> ./out/bin/step-runner run --git-url gitlab-ci-token:${GITLAB_TOKEN}@gitlab.com/ra-group2/ra-step --git-rev ra/test --git-dir steps/dummy --inputs project_name=HelloWindows
Running step name=step
HelloWindows

close #308 (closed)

Edited by Romuald Atchadé

Merge request reports

Loading