fix: --auth when --git-user contains space (#95)

Since --git-user is a user-facing name, it's common to include a space
in it. As such, it's not suitable to use as a username in a Git remote
URL.

GitLab documented that it doesn't (yet?) check for username [1], and
from my testing GitHub doesn't seem to care either. So just use an
arbitrary name as a username.

[1] https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html
This commit is contained in:
Ratchanan Srirattanamet 2024-02-23 16:30:18 +07:00 committed by GitHub
parent d4dc510af1
commit 9bcd6e6b55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 6 deletions

5
dist/cli/index.js vendored
View file

@ -493,8 +493,9 @@ class GitCLIService {
* @param remoteURL remote link, e.g., https://github.com/kiegroup/git-backporting-example.git
*/
remoteWithAuth(remoteURL) {
if (this.auth && this.gitData.user) {
return remoteURL.replace("://", `://${this.gitData.user}:${this.auth}@`);
if (this.auth) {
// Anything will work as a username.
return remoteURL.replace("://", `://token:${this.auth}@`);
}
// return remote as it is
return remoteURL;