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 = [
14
14
" ^run_release.py$" ,
15
15
" ^sbom.py$" ,
16
16
" ^tests/test_release_tag.py$" ,
17
+ " ^tests/test_run_release.py$" ,
17
18
" ^tests/test_sbom.py$" ,
18
19
" ^windows-release/purge.py$" ,
19
20
]
Original file line number Diff line number Diff line change @@ -738,6 +738,17 @@ def execute_command(command: str) -> None:
738
738
execute_command (f"find { destination } -type f -exec chmod 664 {{}} \\ ;" )
739
739
740
740
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
+
741
752
def start_build_of_source_and_docs (db : DbfilenameShelf ) -> None :
742
753
# Get the git commit SHA for the tag
743
754
commit_sha = (
@@ -757,14 +768,7 @@ def start_build_of_source_and_docs(db: DbfilenameShelf) -> None:
757
768
.decode ()
758
769
.strip ()
759
770
)
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 )
768
772
# We ask for human verification at this point since this commit SHA is 'locked in'
769
773
print ()
770
774
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 =
9
9
skip_install = true
10
10
deps =
11
11
-r dev-requirements.txt
12
+ -r requirements.txt
12
13
commands =
13
14
{envpython} -m pytest \
14
15
tests/ \
You can’t perform that action at this time.
0 commit comments