File tree Expand file tree Collapse file tree 4 files changed +38
-8
lines changed Expand file tree Collapse file tree 4 files changed +38
-8
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ exclude = [
1414 " ^run_release.py$" ,
1515 " ^sbom.py$" ,
1616 " ^tests/test_release_tag.py$" ,
17+ " ^tests/test_run_release.py$" ,
1718 " ^tests/test_sbom.py$" ,
1819 " ^windows-release/purge.py$" ,
1920]
Original file line number Diff line number Diff line change @@ -738,6 +738,17 @@ def execute_command(command: str) -> None:
738738 execute_command (f"find { destination } -type f -exec chmod 664 {{}} \\ ;" )
739739
740740
741+ def extract_github_owner (url : str ) -> str :
742+ if https_match := re .match (r"(https://)?github\.com/([^/]+)/" , url ):
743+ return https_match .group (2 )
744+ elif ssh_match := re .match (r"^git@github\.com:([^/]+)/" , url ):
745+ return ssh_match .group (1 )
746+ else :
747+ raise ReleaseException (
748+ f"Could not parse GitHub owner from 'origin' remote URL: { url } "
749+ )
750+
751+
741752def start_build_of_source_and_docs (db : DbfilenameShelf ) -> None :
742753 # Get the git commit SHA for the tag
743754 commit_sha = (
@@ -757,14 +768,7 @@ def start_build_of_source_and_docs(db: DbfilenameShelf) -> None:
757768 .decode ()
758769 .strip ()
759770 )
760- if https_match := re .match (r"github\.com/([^/]+)/" , origin_remote_url ):
761- origin_remote_github_owner = https_match .group (1 )
762- elif ssh_match := re .match (r"^git@github\.com:([^/]+)/" , origin_remote_url ):
763- origin_remote_github_owner = ssh_match .group (1 )
764- else :
765- raise ReleaseException (
766- f"Could not parse GitHub owner from 'origin' remote URL: { origin_remote_url } "
767- )
771+ origin_remote_github_owner = extract_github_owner (origin_remote_url )
768772 # We ask for human verification at this point since this commit SHA is 'locked in'
769773 print ()
770774 print (
Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ import run_release
4+
5+
6+ @pytest .mark .parametrize (
7+ ["url" , "expected" ],
8+ [
9+ ("github.com/hugovk/cpython.git" , "hugovk" ),
10+ ("[email protected] :hugovk/cpython.git" , "hugovk" ), 11+ ("https://github.com/hugovk/cpython.git" , "hugovk" ),
12+ ],
13+ )
14+ def test_extract_github_owner (url : str , expected : str ) -> None :
15+ assert run_release .extract_github_owner (url ) == expected
16+
17+
18+ def test_invalid_extract_github_owner () -> None :
19+ with pytest .raises (
20+ run_release .ReleaseException ,
21+ match = "Could not parse GitHub owner from 'origin' remote URL: "
22+ "https://example.com" ,
23+ ):
24+ run_release .extract_github_owner ("https://example.com" )
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ env_list =
99skip_install = true
1010deps =
1111 -r dev-requirements.txt
12+ -r requirements.txt
1213commands =
1314 {envpython} -m pytest \
1415 tests/ \
You can’t perform that action at this time.
0 commit comments