chris-peterson / pwsh-gitlab

:computer: PowerShell module for GitLab
MIT License
22 stars 10 forks source link

Improve error handling #97

Closed Stephanevg closed 1 month ago

Stephanevg commented 2 months ago

I face an issue, which was very 'combersome' for me to troubleshoot.

Ultimatley, it was all my fault, because I was declaring my base url as follows:

$pat = "CrazyPat123"
$BaseUrl = "https://my.gitlabbaseurl.com/"

$env:GITLAB_ACCESS_TOKEN = $Pat
$env:GITLAB_URL = $BaseUrl

instead of

$pat = "CrazyPat123"
$BaseUrl = "https://my.gitlabbaseurl.com" #notice the  trailing '/' is not present anymore

$env:GITLAB_ACCESS_TOKEN = $Pat
$env:GITLAB_URL = $BaseUrl

Since -Verbose didn't work (see #96 ) It took me a bit of time to understand what was wrong.

We could potentially just add some logic to remove the trailing '/' if it is found on the $env:GITLAB_URL variable. Maybe in Set-DefaultGitlabSite ?

Or maybe add a function called Set-GitLabBaseUrl which would actually do that cleanup, before writing it to the $env:GITLAB_URL variable.

I would be happy to write the fix and add a PR, just let me know.

chris-peterson commented 1 month ago

Fixed in https://github.com/chris-peterson/pwsh-gitlab/commit/cf2c57f9196bcc975753ef1b8664e0c26413d8bb