Skip to content

Commit c99ce5d

Browse files
steverydzCopilot
andauthored
fix: Show repo owner in builds repo selector (#5417)
* fix: Show repo owner in builds repo selector * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update webapp/api/github.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update static/js/publisher/pages/Builds/RepoSelector.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix test to accomodate nameWithOwner field * Update webapp/api/github.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix linting error --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 97e3d50 commit c99ce5d

3 files changed

Lines changed: 164 additions & 153 deletions

File tree

static/js/publisher/pages/Builds/RepoSelector.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { buildRepoConnectedState } from "../../state/buildsState";
2121

2222
import type { GithubData } from "../../types/";
2323

24-
type Repo = { name: string; nameWithOwner: string };
24+
type Repo = { name: string; nameWithOwner: string; owner: string };
2525

2626
type Props = {
2727
githubData: GithubData;
@@ -172,7 +172,9 @@ function RepoSelector({ githubData, setAutoTriggerBuild }: Props) {
172172
}
173173

174174
const responseData = await response.json();
175-
setRepos(responseData);
175+
setRepos(
176+
responseData.sort((a: Repo, b: Repo) => a.name.localeCompare(b.name)),
177+
);
176178
} catch (_error) {
177179
setRepoFetchError("Failed to fetch repositories. Please try again.");
178180
setRepos([]);
@@ -332,7 +334,9 @@ function RepoSelector({ githubData, setAutoTriggerBuild }: Props) {
332334
))}
333335
<datalist id="repo-list">
334336
{repos.map((repo: Repo) => (
335-
<option value={repo.name} key={repo.name} />
337+
<option value={repo.name} key={repo.name}>
338+
{repo.owner !== selectedOrg ? `Owned by ${repo.owner}` : ""}
339+
</option>
336340
))}
337341
</datalist>
338342
{repoFetchError && (
Lines changed: 147 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,149 @@
11
interactions:
2-
- request:
3-
body: '{"query": "{\n viewer {\n repositories(\n first:
4-
100,\n privacy: PUBLIC,\n ownerAffiliations:
5-
[OWNER],\n \n ) {\n edges {\n node
6-
{\n name\n }\n }\n pageInfo
7-
{\n hasNextPage\n endCursor\n }\n }\n }\n }"}'
8-
headers:
9-
Accept:
10-
- application/json
11-
Accept-Encoding:
12-
- gzip, deflate
13-
Connection:
14-
- keep-alive
15-
Content-Length:
16-
- '473'
17-
Content-Type:
18-
- application/json
19-
User-Agent:
20-
- storefront (516d523a5dba207e721d0f8e56d031af100ce611;devel)
21-
method: POST
22-
uri: https://api.github.com/graphql
23-
response:
24-
body:
25-
string: !!binary |
26-
H4sIAAAAAAAAA3WPPwvCMBDFv8vNWWx1sNBBdLAIxkko4nCYa41oEpL4J4Z+d5Pd3HLv3g8e7yII
27-
9AhNhJekN9msLBntpNdWkss3iTGLUwSlBWVH4SNt8OT8DKaJ/SVVkdRFMi+SRSJnBgZH6tSgc4sr
28-
uj19/CFZ0Ax4d8SAlFg/rdPpEejrY7hUy8BVH7jZ8s1t131XbZuS0vwAWZ+8kvoAAAA=
29-
headers:
30-
Access-Control-Allow-Origin:
31-
- '*'
32-
Access-Control-Expose-Headers:
33-
- ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining,
34-
X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval,
35-
X-GitHub-Media-Type
36-
Cache-Control:
37-
- no-cache
38-
Content-Encoding:
39-
- gzip
40-
Content-Security-Policy:
41-
- default-src 'none'
42-
Content-Type:
43-
- application/json; charset=utf-8
44-
Date:
45-
- Mon, 17 Feb 2020 13:33:31 GMT
46-
Referrer-Policy:
47-
- origin-when-cross-origin, strict-origin-when-cross-origin
48-
Server:
49-
- GitHub.com
50-
Status:
51-
- 200 OK
52-
Strict-Transport-Security:
53-
- max-age=31536000; includeSubdomains; preload
54-
Transfer-Encoding:
55-
- chunked
56-
Vary:
57-
- Accept-Encoding, Accept, X-Requested-With
58-
X-Accepted-OAuth-Scopes:
59-
- repo
60-
X-Content-Type-Options:
61-
- nosniff
62-
X-Frame-Options:
63-
- deny
64-
X-GitHub-Media-Type:
65-
- github.v4
66-
X-GitHub-Request-Id:
67-
- AA88:D864:762CC31:8C7B0A0:5E4A962A
68-
X-OAuth-Client-Id:
69-
- cdeb3a60fecee4208395
70-
X-OAuth-Scopes:
71-
- read:org, repo
72-
X-RateLimit-Limit:
73-
- '5000'
74-
X-RateLimit-Remaining:
75-
- '4998'
76-
X-RateLimit-Reset:
77-
- '1581950009'
78-
X-XSS-Protection:
79-
- 1; mode=block
80-
status:
81-
code: 200
82-
message: OK
83-
- request:
84-
body: '{"query": "{\n viewer {\n repositories(\n first:
85-
100,\n privacy: PUBLIC,\n ownerAffiliations:
86-
[OWNER],\n \n ) {\n edges {\n node
87-
{\n name\n }\n }\n pageInfo
88-
{\n hasNextPage\n endCursor\n }\n }\n }\n }"}'
89-
headers:
90-
Accept:
91-
- application/json
92-
Accept-Encoding:
93-
- gzip, deflate
94-
Connection:
95-
- keep-alive
96-
Content-Length:
97-
- '473'
98-
Content-Type:
99-
- application/json
100-
User-Agent:
101-
- storefront (516d523a5dba207e721d0f8e56d031af100ce611;devel)
102-
method: POST
103-
uri: https://api.github.com/graphql
104-
response:
105-
body:
106-
string: '{"message":"Bad credentials","documentation_url":"https://developer.github.com/v4"}'
107-
headers:
108-
Access-Control-Allow-Origin:
109-
- '*'
110-
Access-Control-Expose-Headers:
111-
- ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining,
112-
X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval,
113-
X-GitHub-Media-Type
114-
Content-Length:
115-
- '83'
116-
Content-Security-Policy:
117-
- default-src 'none'
118-
Content-Type:
119-
- application/json; charset=utf-8
120-
Date:
121-
- Mon, 17 Feb 2020 13:33:31 GMT
122-
Referrer-Policy:
123-
- origin-when-cross-origin, strict-origin-when-cross-origin
124-
Server:
125-
- GitHub.com
126-
Status:
127-
- 401 Unauthorized
128-
Strict-Transport-Security:
129-
- max-age=31536000; includeSubdomains; preload
130-
Vary:
131-
- Accept-Encoding, Accept, X-Requested-With
132-
X-Content-Type-Options:
133-
- nosniff
134-
X-Frame-Options:
135-
- deny
136-
X-GitHub-Media-Type:
137-
- github.v4
138-
X-GitHub-Request-Id:
139-
- AA88:D864:762CD9B:8C7B1F5:5E4A962B
140-
X-RateLimit-Limit:
141-
- '0'
142-
X-RateLimit-Remaining:
143-
- '0'
144-
X-RateLimit-Reset:
145-
- '1581950011'
146-
X-XSS-Protection:
147-
- 1; mode=block
148-
status:
149-
code: 401
150-
message: Unauthorized
2+
- request:
3+
body:
4+
'{"query": "{\n viewer {\n repositories(\n first:
5+
100,\n privacy: PUBLIC,\n \n )
6+
{\n edges {\n node {\n name\n nameWithOwner\n }\n }\n pageInfo
7+
{\n hasNextPage\n endCursor\n }\n }\n }\n }"}'
8+
headers:
9+
Accept:
10+
- application/json
11+
Accept-Encoding:
12+
- gzip, deflate
13+
Connection:
14+
- keep-alive
15+
Content-Length:
16+
- "457"
17+
Content-Type:
18+
- application/json
19+
User-Agent:
20+
- storefront (516d523a5dba207e721d0f8e56d031af100ce611;devel)
21+
method: POST
22+
uri: https://api.github.com/graphql
23+
response:
24+
body:
25+
string: '{"data":{"viewer":{"repositories":{"edges":[{"node":{"name":"test1","nameWithOwner":"testuser/test1"}},{"node":{"name":"test2","nameWithOwner":"testuser/test2"}},{"node":{"name":"test3","nameWithOwner":"testuser/test3"}},{"node":{"name":"test4","nameWithOwner":"testuser/test4"}},{"node":{"name":"test5","nameWithOwner":"testuser/test5"}}],"pageInfo":{"hasNextPage":false,"endCursor":"Y3Vyc29yOnYyOpHODjKIzA=="}}}}}'
26+
headers:
27+
Access-Control-Allow-Origin:
28+
- "*"
29+
Access-Control-Expose-Headers:
30+
- ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining,
31+
X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval,
32+
X-GitHub-Media-Type
33+
Cache-Control:
34+
- no-cache
35+
Content-Security-Policy:
36+
- default-src 'none'
37+
Content-Type:
38+
- application/json; charset=utf-8
39+
Date:
40+
- Mon, 17 Feb 2020 13:33:31 GMT
41+
Referrer-Policy:
42+
- origin-when-cross-origin, strict-origin-when-cross-origin
43+
Server:
44+
- GitHub.com
45+
Status:
46+
- 200 OK
47+
Strict-Transport-Security:
48+
- max-age=31536000; includeSubdomains; preload
49+
Vary:
50+
- Accept-Encoding, Accept, X-Requested-With
51+
X-Accepted-OAuth-Scopes:
52+
- repo
53+
X-Content-Type-Options:
54+
- nosniff
55+
X-Frame-Options:
56+
- deny
57+
X-GitHub-Media-Type:
58+
- github.v4
59+
X-GitHub-Request-Id:
60+
- AA88:D864:762CC31:8C7B0A0:5E4A962A
61+
X-OAuth-Client-Id:
62+
- cdeb3a60fecee4208395
63+
X-OAuth-Scopes:
64+
- read:org, repo
65+
X-RateLimit-Limit:
66+
- "5000"
67+
X-RateLimit-Remaining:
68+
- "4998"
69+
X-RateLimit-Reset:
70+
- "1581950009"
71+
X-XSS-Protection:
72+
- 1; mode=block
73+
status:
74+
code: 200
75+
message: OK
76+
- request:
77+
body:
78+
'{"query": "{\n viewer {\n repositories(\n first:
79+
100,\n privacy: PUBLIC,\n \n )
80+
{\n edges {\n node {\n name\n nameWithOwner\n }\n }\n pageInfo
81+
{\n hasNextPage\n endCursor\n }\n }\n }\n }"}'
82+
headers:
83+
Accept:
84+
- application/json
85+
Accept-Encoding:
86+
- gzip, deflate, br, zstd
87+
Connection:
88+
- close
89+
Content-Length:
90+
- "457"
91+
Content-Type:
92+
- application/json
93+
User-Agent:
94+
- storefront (commit_id;devel)
95+
method: POST
96+
uri: https://api.github.com/graphql
97+
response:
98+
body:
99+
string: '{"message":"Bad credentials","documentation_url":"https://docs.github.com/graphql","status":"401"}'
100+
headers:
101+
Access-Control-Allow-Origin:
102+
- "*"
103+
Access-Control-Expose-Headers:
104+
- ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining,
105+
X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes,
106+
X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO,
107+
X-GitHub-Request-Id, Deprecation, Sunset
108+
Content-Length:
109+
- "98"
110+
Content-Security-Policy:
111+
- default-src 'none'
112+
Content-Type:
113+
- application/json; charset=utf-8
114+
Date:
115+
- Tue, 14 Oct 2025 14:04:16 GMT
116+
Referrer-Policy:
117+
- origin-when-cross-origin, strict-origin-when-cross-origin
118+
Server:
119+
- github.com
120+
Strict-Transport-Security:
121+
- max-age=31536000; includeSubdomains; preload
122+
Vary:
123+
- Accept-Encoding, Accept, X-Requested-With
124+
X-Content-Type-Options:
125+
- nosniff
126+
X-Frame-Options:
127+
- deny
128+
X-GitHub-Media-Type:
129+
- github.v4
130+
X-GitHub-Request-Id:
131+
- EA4D:41CE:7AFD5A:95CF9A:68EE5860
132+
X-RateLimit-Limit:
133+
- "0"
134+
X-RateLimit-Remaining:
135+
- "0"
136+
X-RateLimit-Reset:
137+
- "1760454256"
138+
X-RateLimit-Resource:
139+
- graphql
140+
X-RateLimit-Used:
141+
- "0"
142+
X-XSS-Protection:
143+
- "0"
144+
connection:
145+
- close
146+
status:
147+
code: 401
148+
message: Unauthorized
151149
version: 1

webapp/api/github.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,16 @@ def get_user_repositories(self, end_cursor=None):
215215
next_page = self.get_user_repositories(page_info["endCursor"])
216216
repositories.extend(next_page)
217217

218-
return repositories
218+
repos = [
219+
(
220+
{**repo, "owner": repo.get("nameWithOwner", "").split("/")[0]}
221+
if "nameWithOwner" in repo and repo.get("nameWithOwner")
222+
else {**repo, "owner": None}
223+
)
224+
for repo in repositories
225+
]
226+
227+
return repos
219228

220229
def get_org_repositories(self, org_login, end_cursor=None):
221230
"""

0 commit comments

Comments
 (0)