Consolidate build URL helpers into helpers/url with auth flag

What does this MR do?

Consolidates the git auth URL helper logic from common/build_url_helper.go into a new, reusable helpers/url/gitauth.go package, and removes dead code from the helpers/url package.

Key changes:

  • New helpers/url package (GitAuthHelper): Introduces GitAuthHelper, GitAuthConfig, and GitAuthServerConfig types. The helper is constructed with an authenticated bool flag, replacing the previous two-struct approach (authenticatedURLHelper / unauthenticatedURLHelper). Auth mode is now a single constructor parameter rather than a runtime interface switch.
  • Removes common/build_url_helper.go: The urlHelperConfig, authenticatedURLHelper, unauthenticatedURLHelper, and related helpers are deleted. Build.urlHelper now holds a *url_helpers.GitAuthHelper directly.
  • Simplifies Build.withUrlHelper(): Variables are resolved once up front, the GitAuthConfig is populated with the new Server sub-struct (Host, SSHHost, SSHPort), and the feature flag GitURLsWithoutTokens is passed as the authenticated argument to NewGitAuthHelper (inverted: !ffOn).
  • Removes dead code from helpers/url: ScrubSecrets (scrub_secrets.go) and the SecretsCleanupHook (log/secrets_cleanup.go) along with their tests are deleted, as they were unused.
  • Refactored tests: Once the new GitAuthHelper was proven to work against the original common package tests (see pipeline below), TestGetRemoteURL and TestGetInsteadOfs in common/build_test.go were slimmed down to avoid duplicating the coverage that now lives in helpers/url/gitauth_test.go. The new dedicated unit tests cover both authenticated and unauthenticated modes, SSH URL handling, submodule force-HTTPS rewrites, custom SSH ports/hosts, and fallback behaviour.

Motivation: The scripts-to-steps migration needs to reuse the git auth URL helper outside of the common package. Moving it to helpers/url makes it importable without creating a circular dependency.

What's the best way to test this MR?

  1. The new GitAuthHelper was first validated against the original unmodified common package tests to confirm behavioural parity: Pipeline 2358860522.
  2. Once that was confirmed, the common package tests were refactored to remove duplication with the new helpers/url/gitauth_test.go tests.
  3. The full test suite now passes with the refactored tests in place.

What are the relevant issue numbers?

Closes #39285

Edited by Arran Walker

Merge request reports

Loading