🔧 fix: update condition for getting remote based on credentials and remote URL

The condition for getting the remote based on credentials and remote URL has been updated. Previously, it only checked if credentials had a GitHub token. Now, it also checks if the remote URL is a GitHub URL. This ensures that the correct remote is retrieved based on the credentials and the remote URL.
This commit is contained in:
Scott Chacon 2023-12-06 10:17:47 +01:00 committed by GitButler
parent d0e391ab82
commit ce5c0e36d5

View File

@ -277,7 +277,18 @@ impl Repository {
name: &str,
credentials: &git::credentials::Factory,
) -> Result<git::Remote, RemoteError> {
if credentials.has_github_token() {
let remote = self
.git_repository
.find_remote(name)
.context("failed to find remote")
.map_err(RemoteError::Other)?;
let is_github = remote
.url()
.map(|url| url.map_or(false, |url| url.is_github()))
.unwrap_or(false);
if credentials.has_github_token() && is_github {
self.get_https_remote(name)
} else {
self.get_ssh_remote(name)