fix(ci-status): default branch and repo fixes
Description
- set the default branch to "main" to avoid issues when running outside a git repository
- fixed issues when running the command for a different repository while in a git repository
- fix(ci-status): default branch and repo fixes
Related Issues
Resolves #7780
How has this been tested?
~/Desktop (02:36:34 PM) took 3s
❯ DEBUG=true ~/Projects/cli/bin/glab ci status -R gitlab-org/cli -c
[git remote -v]
2025/02/18 14:39:31 [Repository: gitlab-org/cli]
[git symbolic-ref --quiet --short HEAD]
2025/02/18 14:39:31 [Current branch: main]
[git config --get-regexp ^branch\.main\.(remote|merge)$]
2025/02/18 14:39:31 [Current branch: main]
(...)
The error is expected, as there isn't a branch named faleksic-ci-status-default-repo for gitlab-org/gitlab>
~/Projects/cli on faleksic-ci-status-default-repo (02:43:00 PM) took 2s
❯ DEBUG=true ./bin/glab ci status -R gitlab-org/gitlab -c
[git remote -v]
[git config --get-regexp ^remote\..*\.glab-resolved$]
2025/02/18 14:43:09 [Repository: gitlab-org/gitlab]
[git symbolic-ref --quiet --short HEAD]
2025/02/18 14:43:09 [Current branch: faleksic-ci-status-default-repo]
[git config --get-regexp ^branch\.faleksic-ci-status-default-repo\.(remote|merge)$]
2025/02/18 14:43:09 [Current branch: faleksic-ci-status-default-repo]
✘ No pipelines running or available on branch: faleksic-ci-status-default-repo
GET https://gitlab.com/api/v4/projects/gitlab-org/gitlab/pipelines/latest: 403 {message: 403 Forbidden}
Supplying the branch name we get the response
~/Projects/cli on faleksic-ci-status-default-repo (02:43:09 PM)
❯ DEBUG=true ./bin/glab ci status -R gitlab-org/gitlab -c --branch master
[git remote -v]
[git config --get-regexp ^remote\..*\.glab-resolved$]
2025/02/18 14:44:23 [Repository: gitlab-org/gitlab]
[git config --get-regexp ^branch\.master\.(remote|merge)$]
2025/02/18 14:44:23 [Current branch: master]
(...)
Screenshots (if appropriate):
Types of changes
-
Bug fix (non-breaking change which fixes an issue) -
New feature (non-breaking change which adds functionality) -
Breaking change (fix or feature that would cause existing functionality to change) -
Documentation -
Chore (Related to CI or Packaging to platforms) -
Test gap
Edited by Filip Aleksic