Skip to content

Commit

Permalink
fix: repo name remote contains profile (#13)
Browse files Browse the repository at this point in the history
When the remote contains a profile it was appended to the repository name. This was caused by #11.

Issue: #11
  • Loading branch information
Joris Conijn authored Jan 27, 2022
1 parent 52389cc commit 7443e7a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pull_request_codecommit/git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def profile(self) -> Optional[str]:
@property
def name(self) -> str:
if not self.__name:
name = self.__regex(r"(\/\/|@)(.*)$", 2)
name = self.__regex(r"(\/\/|.*@)(.*)$", 2)

if name:
self.__name = name
Expand Down
23 changes: 23 additions & 0 deletions tests/test_repository.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest
from unittest.mock import patch, MagicMock
from pull_request_codecommit.repository import Repository


@pytest.mark.parametrize(
"region, profile, repository",
[
("eu-west-1", "my-profile", "my-repository"),
("eu-central-1", "my-other-profile", "my-other-repository"),
],
)
@patch("pull_request_codecommit.repository.GitClient")
def test_remote(
mock_git_client: MagicMock, region: str, profile: str, repository: str
) -> None:
mock_git_client.return_value.remote.return_value = (
f"codecommit::{region}://{profile}@{repository}"
)
repo = Repository("/my/repository")
assert repo.remote.region == region
assert repo.remote.profile == profile
assert repo.remote.name == repository

0 comments on commit 7443e7a

Please sign in to comment.