File tree 2 files changed +27
-13
lines changed
2 files changed +27
-13
lines changed Original file line number Diff line number Diff line change @@ -115,14 +115,27 @@ async def main(cmdline_args: list[str]) -> int:
115
115
116
116
logger .info ("Looking up source URL from target repository" )
117
117
118
- source_url = await github_api .get_repo_property (
119
- repo_url = args .target ,
120
- property_name = args .source [len ("target-prop:" ) :],
121
- )
122
- if source_url is None :
118
+ props = await github_api .get_repo_properties (args .target )
119
+ source_prop_name = args .source [len ("target-prop:" ) :]
120
+
121
+ if source_prop_name not in props :
123
122
logger .error ("Property %s not found in target repository" , args .source )
124
123
return 1
125
124
125
+ source_prop_value = props [source_prop_name ]
126
+ if source_prop_value .startswith ("/" ):
127
+ # Assume it's a relative path and lookup host from another prop
128
+ if f"{ source_prop_name } -host" not in props :
129
+ logger .error (
130
+ "Source property is relative, but no %s-host not found in target repository: %s" ,
131
+ args .source ,
132
+ source_prop_value ,
133
+ )
134
+ return 1
135
+ source_url = props [f"{ source_prop_name } -host" ] + source_prop_value
136
+ else :
137
+ source_url = source_prop_value
138
+
126
139
source = Transport .from_url (source_url , credentials_provider = credentials_provider )
127
140
target = Transport .from_url (args .target , credentials_provider = credentials_provider )
128
141
Original file line number Diff line number Diff line change @@ -49,11 +49,10 @@ def get_org_api(self, org: str) -> github.Github:
49
49
50
50
return github .Github (auth = self ._auth .get_installation_auth (installation_id ))
51
51
52
- async def get_repo_property (
52
+ async def get_repo_properties (
53
53
self ,
54
54
repo_url : str ,
55
- property_name : str ,
56
- ) -> None | str :
55
+ ) -> dict [str , str ]:
57
56
url = urlparse (repo_url )
58
57
59
58
path_parts = url .path .strip ("/" ).split ("/" )
@@ -62,13 +61,15 @@ async def get_repo_property(
62
61
if repo_name .endswith (".git" ):
63
62
repo_name = repo_name [:- 4 ]
64
63
65
- logging .info ("Looking up property %s for org '%s' and repo '%s'" , property_name , org , repo_name )
66
64
api = self .get_org_api (org )
67
65
repo = api .get_repo (f"{ org } /{ repo_name } " )
68
- value = repo .get_custom_properties ().get (property_name , None ) # type: ignore
69
- if value is not None and not isinstance (value , str ):
70
- raise ValueError (f"Property { property_name } is not a string: { value } " )
71
- return value
66
+
67
+ values : dict [str , str ] = {}
68
+ for key , value in repo .custom_properties .items (): # type: ignore
69
+ if isinstance (value , str ):
70
+ values [key ] = value
71
+
72
+ return values
72
73
73
74
def crendentials_provider_for_org (self , org : str ) -> GitHubAppCredentialProvider :
74
75
installation_id = self .get_installation_id (org )
You can’t perform that action at this time.
0 commit comments