fix: use GitLab API for default branch instead of git remote show

What does this MR do and why?

Fixes #8245 (closed). Replaces all uses of git.GetDefaultBranch() (which runs git remote show and fell back to hardcoded "master" on error) with project.DefaultBranch from the GitLab API, which is the authoritative source and already available at every call site.

Changes

  • mr create: use TargetProject.DefaultBranch — the project is already fetched before this point, so no extra API call is needed. Removes the now-redundant getTargetBranch() helper.
  • mr for: fetch project via api.GetProject, use DefaultBranch. Removes the unused remotes/repoRemote fetch and git import.
  • stack reorder: fetch project via api.GetProject, use DefaultBranch.
  • ciutils.GetDefaultBranch: switch from calling client.Projects.GetProject directly to api.GetProject + git.DefaultBranchName for consistency with the rest of the codebase.
  • git.GetDefaultBranch / ParseDefaultBranch: fix error fallback from hardcoded "master" to git.DefaultBranchName ("main").

MR acceptance checklist

  • This MR does not have a documentation impact
  • I have added/updated tests

Merge request reports

Loading